Skip to content

Commit 9c73bd5

Browse files
Merge pull request #15 from Kanaries/codex/complete-missing-algorithms-in-docs
Add missing algorithm docs
2 parents 7f7f85f + 36c4779 commit 9c73bd5

14 files changed

Lines changed: 145 additions & 3 deletions

File tree

docs/_sidebar.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
+ [Algebra(代数)](zh-cn/apis/algebra/index.md)
55
+ [Clusters](zh-cn/apis/clusters/index.md)
66
+ [KMeans](zh-cn/apis/clusters/kmeans.md)
7+
+ [DBScan](zh-cn/apis/clusters/dbscan.md)
78
+ [Ensemble](zh-cn/apis/ensemble.md)
89
+ [IsolationForest(孤立森林)](zh-cn/apis/ensemble/iforest.md)
910
+ [Neighbors](zh-cn/apis/neighbors.md)
1011
+ [KNearstNeighbors(K近邻)](zh-cn/apis/neighbors/knn.md)
1112
+ [Tree](zh-cn/apis/tree/index.md)
12-
+ [DecisionTreeClassifier(决策树分类器)](zh-cn/apis/tree/decisionTreeClassifier.md)
13+
+ [DecisionTreeClassifier(决策树分类器)](zh-cn/apis/tree/decisionTreeClassifier.md)
14+
+ [Linear](zh-cn/apis/linear/index.md)
15+
+ [LinearRegression(线性回归)](zh-cn/apis/linear/linearRegression.md)

docs/en/_sidebar.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
+ APIs
22
+ [Clusters](./apis/clusters.md)
33
+ [Ensemble](./apis/ensemble.md)
4-
+ [Neighbors](./apis/neighbors.md)
4+
+ [Neighbors](./apis/neighbors.md)
5+
+ [Tree](./apis/tree/index.md)
6+
+ [Linear](./apis/linear/index.md)

docs/en/apis/clusters.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,18 @@ const kmeans = new KMeans(2, 0.05, initCenters);
2828

2929
const result = kmeans.fitPredict(X, sampleWeights);
3030

31-
```
31+
```
32+
33+
## Clusters.DBScan
34+
35+
```ts
36+
constructor(eps: number = 0.5, minSamples: number = 5, distanceType: Distance.IDistanceType = 'euclidiean')
37+
```
38+
39+
`fitPredict(samplesX: number[][]): number[]` returns cluster labels for samples. Noise points are marked as `-1`.
40+
41+
```ts
42+
const X = makeCircles(20, 20, 1, 5);
43+
const dbscan = new DBScan(0.6, 3);
44+
const labels = dbscan.fitPredict(X);
45+
```

docs/en/apis/ensemble.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ensemble
2+
3+
## Ensemble.IsolationForest
4+
5+
See [ensemble/iforest.md](ensemble/iforest.md) for details.

docs/en/apis/ensemble/iforest.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## IsolationForest
2+
3+
```ts
4+
constructor(subsampling_size: number = 256, tree_num: number = 100, contamination: 'auto' | number = 'auto')
5+
```
6+
7+
### Methods
8+
+ `fit(samplesX: number[][]): void`
9+
+ `predict(samplesX: number[][]): (0|1)[]`
10+
11+
### Example
12+
```ts
13+
const iForest = new IsolationForest(256, 10, 0.25);
14+
const X = [[-2, -1], [-1, -1], [-1, -2], [1, 1]];
15+
iForest.fit(X);
16+
const result = iForest.predict(X);
17+
```

docs/en/apis/linear/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Linear
2+
3+
- [LinearRegression](linearRegression.md)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## LinearRegression
2+
3+
```ts
4+
constructor()
5+
```
6+
7+
### Methods
8+
+ `fit(X: number[][], Y: number[]): void`
9+
+ `predict(X: number[][]): number[]`
10+
11+
### Example
12+
```ts
13+
const lr = new LinearRegression();
14+
lr.fit([[0], [1]], [1, 3]);
15+
const pred = lr.predict([[2]]); // about 5
16+
```

docs/en/apis/neighbors.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Neighbors
2+
3+
- [KNearstNeighbors](neighbors/knn.md)

docs/en/apis/neighbors/knn.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## KNearstNeighbors
2+
3+
```ts
4+
constructor(
5+
kNeighbors: number = 5,
6+
weightType: IWeightType = 'uniform',
7+
distanceType: Distance.IDistanceType = 'euclidiean',
8+
pNorm: number = 2
9+
)
10+
```
11+
12+
### Example
13+
```ts
14+
const knn = new KNearstNeighbors(3, 'distance', '2-norm');
15+
knn.fit(trainX, trainY);
16+
const result = knn.predict(trainX);
17+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## DecisionTreeClassifier
2+
3+
```ts
4+
interface DecisionTreeProps {
5+
max_depth?: number;
6+
min_samples_split?: number;
7+
criterion?: 'entropy' | 'gini';
8+
}
9+
10+
constructor(props: DecisionTreeProps = {})
11+
```
12+
13+
### Example
14+
```ts
15+
const dt = new DecisionTreeClassifier({ criterion: 'gini' });
16+
dt.fit(X, Y);
17+
const result = dt.predict(T);
18+
```

0 commit comments

Comments
 (0)