https://github.com/ecmadao/ml-in-action
Machine learning in JavaScript
https://github.com/ecmadao/ml-in-action
javascript machine-learning machinelearning
Last synced: 3 months ago
JSON representation
Machine learning in JavaScript
- Host: GitHub
- URL: https://github.com/ecmadao/ml-in-action
- Owner: ecmadao
- Created: 2017-08-11T01:59:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-12T04:04:12.000Z (over 3 years ago)
- Last Synced: 2025-04-11T00:11:52.097Z (9 months ago)
- Topics: javascript, machine-learning, machinelearning
- Language: JavaScript
- Homepage:
- Size: 1.23 MB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ml-in-action
> 用 JavaScript 撸一撸机器学习,不依赖于已封装好的 ml modules
### 目录
#### 监督学习
1. [神经网络](./neural-network)
2. [线性回归](./linear-regression)
3. [逻辑回归](./logistic-regression)
4. [K 邻近分类](./knn)
#### 无监督学习
1. [K 均值聚类](./k-means)
2. SVM
#### 应用
1. 文本数据分析
2. 泰坦尼克号幸存者
### 依赖的包
#### [mathjs](http://mathjs.org/)
> 方便进行矩阵运算
```javascript
const array = [1, 2, 3, 4];
// 转为矩阵
const matrix = math.matrix([array]);
/*
* [
* [1, 2, 3, 4]
* ]
*/
matrix.size(); // => [1, 4]
matrix.valueOf(); // => [[1, 2, 3, 4]]
// 矩阵每一位上的元素都乘以、减去指定数字
math.add(matrix, -1); // 每一位 -1
// [[0, 1, 2, 3]]
math.multiply(-1, matrix); // 每一位 * -1
// [[-1, -2, -3, -4]]
// 转置矩阵
const matrixT = math.transpose(matrix);
matrixT.size(); // => [4, 1]
matrixT.valueOf(); // => [[1], [2], [3], [4]]
/* ================================================ */
const a = [[9, 5], [6, 1]];
const b = [[3, 2], [5, 2]];
// 矩阵相对应位上的元素相加
math.add(a, b); // => [[12, 7], [11, 3]]
// 矩阵相减
math.subtract(a, b); // => [[6, 3], [1, -1]]
// 矩阵相对应位上的元素相乘
math.dotMultiply(a, b); // => [[27, 10], [30, 2]]
// 矩阵相乘
math.multiply(a, b); // => [[52, 28], [23, 14]]
```
### Recommended
- [数据的游戏:冰与火](http://coolshell.cn/articles/10192.html)