Skip to content

Commit 67e4909

Browse files
committed
Update English README.md
1 parent 9ac4748 commit 67e4909

File tree

8 files changed

+456
-172
lines changed

8 files changed

+456
-172
lines changed

src/binning/README.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
# 数值分类
1+
# Binning
2+
**Read this in other languages: [简体中文](./README.zh-CN.md)**
23

3-
本包主要封装数值分类相关接口.
4+
This package mainly encapsulates interfaces related to numerical classification.
45

5-
## 结构体
6+
## Structure
67

78
```go
89
package binning
910

1011
type Calculator struct {
11-
width int32 // 等宽分组参数: 总共分组的组别个数
12-
freq int32 // 等频分组参数: 每组中包含的数值个数
13-
kMeansMaxIter int32 // 聚类分组参数: KMeans算法最大迭代次数
14-
kMeansK int32 //聚类分组参数: KMeans算法k值
12+
width int32 // Equal width grouping parameter: the total number of groups
13+
freq int32 // Equal frequency grouping parameter: the number of values ​​contained in each group
14+
kMeansMaxIter int32 // Clustering grouping parameter: the maximum number of iterations of the KMeans algorithm
15+
kMeansK int32 // Clustering grouping parameter: the k value of the KMeans algorithm
1516
}
1617

1718
```
1819

19-
可以调用 ```func NewCalculator(optionalParam ...int32) Calculator``` 获取对象.
20-
动态参数如果长度等于4则会以 width, freq, kMeansMaxIter, kMeansK 的顺序进行初始化, 如果长度不为4则自动初始化为默认参数.
21-
默认参数信息详见文件 ```src/static.go```
22-
23-
## 接口
24-
25-
1. **ClusterWithKMeansInt32([]int32) ([]int32, error)**
26-
```text
27-
使用K-Means算法对数据进行聚类分组.
28-
注意:
29-
1. 输入数据长度不可为0.
30-
2. k值不可大于数据点的数量.
31-
```
32-
33-
2. **ClusterWithKMeansFloat32([]float32) ([]int32, error)**
34-
```text
35-
使用K-Means算法对数据进行聚类分组.
36-
注意:
37-
1. 输入数据长度不可为0.
38-
2. k值不可大于数据点的数量.
39-
```
40-
41-
3. **EqualWidthBinningInt32([]int32) ([]int32, error)**
42-
```text
43-
对数据进行等宽分组, 分组数量为Calculator.width
44-
返回每个数据点的区间索引.
45-
注意: 输入的数据长度不得为0
46-
```
47-
48-
4. **EqualWidthBinningFloat32([]float32) ([]int32, error)**
49-
```text
50-
对数据进行等宽分组, 分组数量为Calculator.width
51-
返回每个数据点的区间索引.
52-
注意: 输入的数据长度不得为0
53-
```
54-
55-
5. **EqualFrequencyBinningInt32([]int32) ([]int32, error)**
56-
```text
57-
对数据进行等频分组, 每组数据个数为Calculator.freq
58-
返回每个数据点的区间索引.
59-
```
60-
61-
6. **EqualFrequencyBinningFloat32([]float32) ([]int32, error)**
62-
```text
63-
对数据进行等频分组, 每组数据个数为Calculator.freq
64-
返回每个数据点的区间索引.
65-
```
66-
20+
You can call ```func NewCalculator(optionalParam ...int32) Calculator``` to get the object.
21+
If the length of the dynamic parameter is equal to 4, it will be initialized in the order of width, freq, kMeansMaxIter,
22+
kMeansK. If the length is not 4, it will be automatically initialized to the default parameter.
23+
For details about the default parameters, see the file ```src/static.go```
6724

25+
## Interface
26+
27+
### 1.ClusterWithKMeansInt32([]int32) ([]int32, error)
28+
29+
Use the K-Means algorithm to cluster and group data. The slice index returned by the function corresponds to the input
30+
slice, and the slice element is the group number of the value of the index.
31+
> [!IMPORTANT]
32+
> 1. The input data length cannot be 0.
33+
> 2. The k value cannot be greater than the number of data points.
34+
35+
### 2. ClusterWithKMeansFloat32([]float32) ([]int32, error)
36+
37+
Use the K-Means algorithm to cluster and group data. The slice index returned by the function corresponds to the input
38+
slice, and the slice element is the group number of the value of the index.
39+
> [!IMPORTANT]
40+
> 1. The input data length cannot be 0.
41+
> 2. The k value cannot be greater than the number of data points.
42+
43+
### 3. EqualWidthBinningInt32([]int32) ([]int32, error)
44+
45+
Group the data with equal width, the number of groups is Calculator.width. The function returns the interval index of
46+
each data point.
47+
48+
> [!IMPORTANT]
49+
> The length of the input data cannot be 0
50+
51+
### 4. EqualWidthBinningFloat32([]float32) ([]int32, error)
52+
53+
Group the data with equal width, the number of groups is Calculator.width. The function returns the interval index of
54+
each data point.
55+
56+
> [!IMPORTANT]
57+
> The length of the input data cannot be 0
58+
59+
### 5. EqualFrequencyBinningInt32([]int32) ([]int32, error)
60+
61+
Group the data with equal frequency, the number of data in each group is Calculator.freq. The function returns the
62+
interval index of each data point.
63+
64+
### 6. EqualFrequencyBinningFloat32([]float32) ([]int32, error)
65+
66+
Group the data with equal frequency, The number of data points in each group is Calculator.freq. The function returns
67+
the interval index of each data point.

src/binning/README.zh-CN.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# 数值分类
2+
3+
**其他语言版本: [English](./README.md)**
4+
5+
本包主要封装数值分类相关接口.
6+
7+
## 结构体
8+
9+
```go
10+
package binning
11+
12+
type Calculator struct {
13+
width int32 // 等宽分组参数: 总共分组的组别个数
14+
freq int32 // 等频分组参数: 每组中包含的数值个数
15+
kMeansMaxIter int32 // 聚类分组参数: KMeans算法最大迭代次数
16+
kMeansK int32 // 聚类分组参数: KMeans算法k值
17+
}
18+
19+
```
20+
21+
可以调用 ```func NewCalculator(optionalParam ...int32) Calculator``` 获取对象.
22+
动态参数如果长度等于4则会以 width, freq, kMeansMaxIter, kMeansK 的顺序进行初始化, 如果长度不为4则自动初始化为默认参数.
23+
默认参数信息详见文件 ```src/static.go```
24+
25+
## 接口
26+
27+
### 1.ClusterWithKMeansInt32([]int32) ([]int32, error)
28+
29+
使用K-Means算法对数据进行聚类分组. 函数返回的切片下标与输入切片对应, 切片元素为该索引的值的分组组号.
30+
> [!IMPORTANT]
31+
> 1. 输入数据长度不可为0.
32+
> 2. k值不可大于数据点的数量.
33+
34+
### 2. ClusterWithKMeansFloat32([]float32) ([]int32, error)
35+
36+
使用K-Means算法对数据进行聚类分组. 函数返回的切片下标与输入切片对应, 切片元素为该索引的值的分组组号.
37+
> [!IMPORTANT]
38+
> 1. 输入数据长度不可为0.
39+
> 2. k值不可大于数据点的数量.
40+
41+
### 3. EqualWidthBinningInt32([]int32) ([]int32, error)
42+
43+
对数据进行等宽分组, 分组数量为Calculator.width. 函数返回每个数据点的区间索引.
44+
> [!IMPORTANT]
45+
> 输入的数据长度不得为0
46+
47+
### 4. EqualWidthBinningFloat32([]float32) ([]int32, error)
48+
49+
对数据进行等宽分组, 分组数量为Calculator.width. 函数返回每个数据点的区间索引.
50+
51+
> [!IMPORTANT]
52+
> 输入的数据长度不得为0
53+
54+
### 5. EqualFrequencyBinningInt32([]int32) ([]int32, error)
55+
56+
对数据进行等频分组, 每组数据个数为Calculator.freq. 函数返回每个数据点的区间索引.
57+
58+
### 6. EqualFrequencyBinningFloat32([]float32) ([]int32, error)
59+
60+
对数据进行等频分组, 每组数据个数为Calculator.freq. 函数返回每个数据点的区间索引.
61+
62+
63+

src/conversion/README.md

Lines changed: 107 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,118 @@
1-
# 数值转换
1+
# Conversion
2+
**Read this in other languages: [简体中文](./README.zh-CN.md)**
23

3-
本包主要封装数值转换相关接口.
4+
This package mainly encapsulates interfaces related to numerical conversion.
45

5-
## 结构体
6+
## Structure
67

78
```go
89
package conversion
910

1011
type Calculator struct {
11-
logBase float32 //对数计算的底数, 默认为自然数e
12+
logBase float32 //The base of logarithmic calculation, defaults to natural number e
1213
}
1314

1415
```
1516

16-
可以调用 ```func NewCalculator(optionalParam ...float32) Calculator ``` 获取对象. 动态参数如果存在则设置为logBase, 若不存在则默认设置为自然数e.
17-
18-
## 接口
19-
20-
1. **StandardizationInt32([]int32) ([]float32, error)**
21-
```text
22-
最大最小值标准化.
23-
将int32类型的一组数据处理过后数据均落在[0,1]区间内, 处理后输出不再是整数.
24-
计算公式为: normalized=(maxValue−minValue)/(value−minValue)
25-
注意: 无法对零范围(最大最小值相等)的数组进行规范化.
26-
```
27-
28-
2. **StandardizationFloat32([]float32) ([]float32, error)**
29-
```text
30-
最大最小值标准化.
31-
将float32类型的一组数据处理过后数据均落在[0,1]区间内.
32-
计算公式为: normalized=(maxValue−minValue)/(value−minValue)
33-
注意: 无法对零范围(最大最小值相等)的数组进行规范化.
34-
```
35-
3. **ZScoreInt32([]int32) ([]float32, error)**
36-
```text
37-
Z-Score标准化.
38-
计算公式为: Z=(X−μ)/σ
39-
X 是原始数据, μ 是数据的平均值, σ 是数据的标准差
40-
注意: 无法对零范围(最大最小值相等)的数组进行规范化.
41-
```
42-
4. **ZScoreFloat32([]float32) ([]float32, error)**
43-
```text
44-
Z-Score标准化.
45-
计算公式为: Z=(X−μ)/σ
46-
X 是原始数据, μ 是数据的平均值, σ 是数据的标准差
47-
注意: 无法对零范围(最大最小值相等)的数组进行规范化.
48-
```
49-
5. **LogInt32([]int32) ([]float32, error)**
50-
```text
51-
计算对数.
52-
计算公式为: log(base, x), base默认为自然数e.
53-
注意: 需保证输入参数均为正数, 否则:
54-
Log(+Inf) = +Inf
55-
Log(0) = -Inf
56-
Log(x < 0) = NaN
57-
Log(NaN) = NaN
58-
```
59-
6. **LogFloat32([]float32) ([]float32, error)**
60-
```text
61-
计算对数.
62-
计算公式为: log(base, x), base默认为自然数e.
63-
注意: 需保证输入参数均为正数, 否则:
64-
Log(+Inf) = +Inf
65-
Log(0) = -Inf
66-
Log(x < 0) = NaN
67-
Log(NaN) = NaN
68-
```
69-
7. **SquareInt32([]int32) ([]float32, error)**
70-
```text
71-
计算平方根.
72-
计算公式为: √x
73-
注意: 需保证输入参数均为非负实数, 否则:
74-
Sqrt(+Inf) = +Inf
75-
Sqrt(±0) = ±0
76-
Sqrt(x < 0) = NaN
77-
Sqrt(NaN) = NaN
78-
```
79-
8. **SquareFloat32([]float32) ([]float32, error)**
80-
```text
81-
计算平方根.
82-
计算公式为: √x
83-
注意: 需保证输入参数均为非负实数, 否则:
84-
Sqrt(+Inf) = +Inf
85-
Sqrt(±0) = ±0
86-
Sqrt(x < 0) = NaN
87-
Sqrt(NaN) = NaN
88-
```
17+
You can call ```func NewCalculator(optionalParam ...float32) Calculator ``` to get the object. If the dynamic parameter exists, it is set to logBase. If it does not exist, it is set to natural number e by default.
18+
19+
## Interface
20+
21+
### 1. StandardizationInt32([]int32) ([]float32, error)
22+
23+
Maximum and minimum value standardization.
24+
25+
After processing a set of int32 type data, the data all fall within the range of [0, 1]. After processing, the output is no longer an integer.
26+
27+
The calculation formula is:
28+
$$normalized=(maxValue−minValue)/(value−minValue)$$
29+
30+
> [!IMPORTANT]
31+
> It is not possible to normalize an array with zero range (equal maximum and minimum values).
32+
33+
### 2. StandardizationFloat32([]float32) ([]float32, error)
34+
35+
Maximum and minimum value normalization.
36+
37+
After processing a set of float32 data, the data all fall within the interval [0, 1].
38+
39+
The calculation formula is:
40+
$$normalized=(maxValue−minValue)/(value−minValue)$$
41+
42+
> [!IMPORTANT]
43+
> It is not possible to normalize an array with zero range (equal maximum and minimum values).
44+
45+
### 3. ZScoreInt32([]int32) ([]float32, error)
46+
47+
Z-Score standardization.
48+
49+
The calculation formula is:
50+
$$Z=(X−\mu)/\sigma$$
51+
52+
$X$ is the original data, $\mu$ is the mean value of the data, and $\sigma$ is the standard deviation of the data.
53+
54+
> [!IMPORTANT]
55+
> Cannot normalize an array with zero range (equal maximum and minimum values).
56+
57+
### 4. ZScoreFloat32([]float32) ([]float32, error)
58+
59+
Z-Score normalization.
60+
61+
The calculation formula is:
62+
$$Z=(X−\mu)/\sigma$$
63+
64+
$X$ is the original data, $\mu$ is the mean value of the data, and $\sigma$ is the standard deviation of the data.
65+
66+
### 5. LogInt32([]int32) ([]float32, error)
67+
Calculate the logarithm.
68+
The calculation formula is:
69+
$$log(base, x)$$
70+
> [!TIP]
71+
> base defaults to the natural number e
72+
73+
> [!IMPORTANT]
74+
> Make sure that all input parameters are positive, otherwise:
75+
> Log(+Inf) = +Inf
76+
> Log(0) = -Inf
77+
> Log(x < 0) = NaN
78+
> Log(NaN) = NaN
79+
80+
### 6. LogFloat32([]float32) ([]float32, error)
81+
Calculates logarithm.
82+
Calculation formula:
83+
$$log(base, x)$$
84+
> [!TIP]
85+
> base defaults to natural number e
86+
87+
> [!IMPORTANT]
88+
> Input parameters must be positive, otherwise:
89+
> Log(+Inf) = +Inf
90+
> Log(0) = -Inf
91+
> Log(x < 0) = NaN
92+
> Log(NaN) = NaN
93+
94+
### 7. SquareInt32([]int32) ([]float32, error)
95+
Calculates square root.
96+
97+
Calculation formula:
98+
$$\sqrt{x}$$
99+
100+
> [!IMPORTANT]
101+
> Input parameters must be non-negative real numbers, otherwise:
102+
> Sqrt(+Inf) = +Inf
103+
> Sqrt(±0) = ±0
104+
> Sqrt(x < 0) = NaN
105+
> Sqrt(NaN) = NaN
106+
107+
### 8. SquareFloat32([]float32) ([]float32, error)
108+
Calculate the square root.
109+
110+
The calculation formula is:
111+
$$\sqrt{x}$$
112+
113+
> [!IMPORTANT]
114+
> Ensure that all input parameters are non-negative real numbers, otherwise:
115+
> Sqrt(+Inf) = +Inf
116+
> Sqrt(±0) = ±0
117+
> Sqrt(x < 0) = NaN
118+
> Sqrt(NaN) = NaN

0 commit comments

Comments
 (0)