Skip to content

Commit

Permalink
Release v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sun1638650145 committed Jun 30, 2022
1 parent 4656686 commit 4c920f5
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 15 deletions.
2 changes: 1 addition & 1 deletion classicML/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""An easy-to-use ML framework."""
__version__ = '0.9b0'
__version__ = '0.9'

import os
import logging
Expand Down
2 changes: 1 addition & 1 deletion classicML/backend/cc/kernels/kernels_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,5 @@ Sigmoid核函数.
.def("__call__", &kernels::Sigmoid::PyCall<matrix32>, pybind11::arg("x_i"), pybind11::arg("x_j"))
.def("__call__", &kernels::Sigmoid::PyCall<matrix64>, pybind11::arg("x_i"), pybind11::arg("x_j"));

m.attr("__version__") = "backend.cc.kernels.0.10.4b0";
m.attr("__version__") = "backend.cc.kernels.0.10.4";
}
2 changes: 1 addition & 1 deletion classicML/backend/cc/ops/ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ Matrix InitCentroids2(const Matrix &x, const Dtype &n_clusters, Matrix init) {
}
} else {
pybind11::print("ERROR:classicML:你使用了非法的均值向量.");
throw pybind11::type_error("你使用了非法的均值向量.");
throw pybind11::value_error("你使用了非法的均值向量.");
}
}

Expand Down
26 changes: 21 additions & 5 deletions classicML/backend/cc/ops/ops_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ PYBIND11_MODULE(ops, m) {
list or numpy.ndarray: 可以指定训练数据的索引, 也可以直接给定具体的均值向量.
Return:
均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
均值向量.
Raises:
ValueError: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
TypeError: 非法均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
m.def("cc_init_centroids", &ops::InitCentroids1<matrix64, uint64>, R"pbdoc(
初始化初始均值向量.
Expand All @@ -539,7 +543,11 @@ PYBIND11_MODULE(ops, m) {
list or numpy.ndarray: 可以指定训练数据的索引, 也可以直接给定具体的均值向量.
Return:
均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
均值向量.
Raises:
ValueError: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
TypeError: 非法均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
m.def("cc_init_centroids", &ops::InitCentroids2<matrix32, uint32>, R"pbdoc(
初始化初始均值向量.
Expand All @@ -551,7 +559,11 @@ PYBIND11_MODULE(ops, m) {
list or numpy.ndarray: 可以指定训练数据的索引, 也可以直接给定具体的均值向量.
Return:
均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
均值向量.
Raises:
ValueError: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
TypeError: 非法均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
m.def("cc_init_centroids", &ops::InitCentroids2<matrix64, uint64>, R"pbdoc(
初始化初始均值向量.
Expand All @@ -563,7 +575,11 @@ PYBIND11_MODULE(ops, m) {
list or numpy.ndarray: 可以指定训练数据的索引, 也可以直接给定具体的均值向量.
Return:
均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));
均值向量.
Raises:
ValueError: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
TypeError: 非法均值向量.)pbdoc", pybind11::arg("x"), pybind11::arg("n_clusters"), pybind11::arg("init"));

// Overloaded function.
m.def("cc_select_second_alpha", &ops::SelectSecondAlpha<np_float32, row_vector32f>, R"pbdoc(
Expand Down Expand Up @@ -692,5 +708,5 @@ PYBIND11_MODULE(ops, m) {
- 注意此函数为CC版本, 暂不能处理多字符的str类型的数据.
)pbdoc", pybind11::arg("y"));

m.attr("__version__") = "backend.cc.ops.0.14b1";
m.attr("__version__") = "backend.cc.ops.0.14";
}
2 changes: 1 addition & 1 deletion classicML/backend/python/kernels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""classicML的核函数."""
import numpy as np

__version__ = 'backend.python.kernels.0.10.4b0'
__version__ = 'backend.python.kernels.0.10.4'


class Kernel(object):
Expand Down
10 changes: 7 additions & 3 deletions classicML/backend/python/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from classicML import _cml_precision
from classicML import CLASSICML_LOGGER

__version__ = 'backend.python.ops.0.14b1'
__version__ = 'backend.python.ops.0.14'


def bootstrap_sampling(x, y=None, seed=None):
Expand Down Expand Up @@ -479,6 +479,10 @@ def init_centroids(x: np.ndarray,
- 该函数提供了非Python后端的实现版本,
你可以使用其他的版本, 函数的调用方式和接口一致,
Python版本是没有优化的原始公式版本.
Raises:
ValueError: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
TypeError: 非法均值向量.
"""
if init == 'random':
centroid_indices = np.random.randint(low=0, high=len(x), size=n_clusters)
Expand All @@ -487,8 +491,8 @@ def init_centroids(x: np.ndarray,
init = np.squeeze(init)
if len(init.shape) == 1: # 指定训练数据的索引.
if len(init) != n_clusters:
CLASSICML_LOGGER.error('你设置聚类簇数量与初始化均值向量数量不一致[%d, %d].', len(init), n_clusters)
raise ValueError('你设置聚类簇数量与初始化均值向量数量不一致[%d, %d].' % (len(init), n_clusters))
CLASSICML_LOGGER.error('你设置聚类簇数量与初始化均值向量数量不一致[%d, %d].', n_clusters, len(init))
raise ValueError('你设置聚类簇数量与初始化均值向量数量不一致[%d, %d].' % (n_clusters, len(init)))
elif np.min(init) < 0 or np.max(init) >= len(x):
CLASSICML_LOGGER.error('你使用了非法的索引(请检查索引是否越界或负值).')
raise ValueError('你使用了非法的索引(请检查索引是否越界或负值).')
Expand Down
5 changes: 5 additions & 0 deletions docs/source/backend/cc/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ cc_init_centroids(x, n_clusters, init)

均值向量.

### 异常

* <b>ValueError</b>: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
* <b>TypeError</b>: 非法均值向量.

## cc_select_second_alpha

```python
Expand Down
5 changes: 5 additions & 0 deletions docs/source/backend/python/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ init_centroids(x, n_clusters, init)

均值向量.

### 异常

* <b>ValueError</b>: 聚类簇数量与初始化均值向量数量不一致, 非法索引或不能自动转换的非法均值向量.
* <b>TypeError</b>: 非法均值向量.

## select_second_alpha

```python
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
author = 'Steve R. Sun'

# 版本号
release = '0.9b0'
release = '0.9'

# markdown插件
extensions = [
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

setup(
name='classicML',
version='0.9b0',
version='0.9',
description='An easy-to-use ML framework',
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -88,7 +88,7 @@
packages=find_packages(),
ext_modules=extension_modules,
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: C++',
Expand Down

0 comments on commit 4c920f5

Please sign in to comment.