Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit 1ed1d59

Browse files
committed
chore: update project to current code style
1 parent 5471fbc commit 1ed1d59

File tree

16 files changed

+436
-4255
lines changed

16 files changed

+436
-4255
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extends: 'eslint-config-cheminfo'
1+
extends: cheminfo
22
parserOptions:
33
sourceType: module
4-
env:
5-
jest: true

.github/workflows/nodejs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 14.x
16+
- name: npm install and lint
17+
run: |
18+
npm install
19+
npm run eslint
20+
test:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
node-version: [10.x, 12.x, 14.x]
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Use Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
- name: npm install and test
32+
run: |
33+
npm install
34+
npm run test-coverage
35+
- name: Send coverage report to Codecov
36+
uses: codecov/codecov-action@v1

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 ml.js
3+
Copyright (c) 2020 ml.js
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,58 @@
11
# logistic-regression
22

3-
[![NPM version][npm-image]][npm-url]
4-
[![build status][travis-image]][travis-url]
5-
[![npm download][download-image]][download-url]
3+
[![NPM version][npm-image]][npm-url]
4+
[![build status][ci-image]][ci-url]
5+
[![Test coverage][codecov-image]][codecov-url]
6+
[![npm download][download-image]][download-url]
67

7-
This is an implementation of the logistic regression. When there are more than 2 classes, the method used is the *One VS All*.
8+
This is an implementation of the logistic regression. When there are more than 2 classes, the method used is the _One VS All_.
89

910
## Installation
1011

11-
`$ npm install --save ml-logistic-regression`
12+
`$ npm i ml-logistic-regression`
1213

1314
## Usage
1415

15-
```javascript
16-
const {Matrix} = require('ml-matrix');
16+
```js
17+
const { Matrix } = require('ml-matrix');
18+
19+
// Our training set (X,Y).
20+
const X = new Matrix([[0, -1], [1, 0], [1, 1], [1, -1], [2, 0], [2, 1], [2, -1], [3, 2], [0, 4], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [1, 10], [1, 12], [2, 10], [2, 11], [2, 14], [3, 11]]);
21+
const Y = Matrix.columnVector([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]);
22+
23+
// The test set (Xtest, Ytest).
24+
const Xtest = new Matrix([
25+
[0, -2],
26+
[1, 0.5],
27+
[1.5, -1],
28+
[1, 2.5],
29+
[2, 3.5],
30+
[1.5, 4],
31+
[1, 10.5],
32+
[2.5, 10.5],
33+
[2, 11.5],
34+
]);
35+
const Ytest = Matrix.columnVector([0, 0, 0, 1, 1, 1, 2, 2, 2]);
36+
37+
// We will train our model.
38+
const logreg = new LogisticRegression({ numSteps: 1000, learningRate: 5e-3 });
39+
logreg.train(X, Y);
40+
41+
// We try to predict the test set.
42+
const finalResults = logreg.predict(Xtest);
1743

18-
// our training set (X,Y)
19-
var X = new Matrix([[0,-1], [1,0], [1,1], [1,-1], [2,0], [2,1], [2,-1], [3,2], [0,4], [1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [1, 10], [1, 12], [2, 10], [2,11], [2, 14], [3, 11]]);
20-
var Y = Matrix.columnVector([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]);
21-
22-
// the test set (Xtest, Ytest)
23-
var Xtest = new Matrix([[0, -2], [1, 0.5], [1.5, -1], [1, 2.5], [2, 3.5], [1.5, 4], [1, 10.5], [2.5, 10.5], [2, 11.5]])
24-
var Ytest = Matrix.columnVector([0, 0, 0, 1, 1, 1, 2, 2, 2]);
25-
26-
// we will train our model
27-
var logreg = new LogisticRegression({numSteps: 1000, learningRate: 5e-3});
28-
logreg.train(X,Y);
29-
30-
// we try to predict the test set
31-
var finalResults = logreg.predict(Xtest);
3244
// Now, you can compare finalResults with the Ytest, which is what you wanted to have.
3345
```
3446

3547
## License
3648

37-
[MIT](./LICENSE)
49+
[MIT](./LICENSE)
3850

39-
[npm-image]: https://img.shields.io/npm/v/ml-logistic-regression.svg?style=flat-square
51+
[npm-image]: https://img.shields.io/npm/v/ml-logistic-regression.svg
4052
[npm-url]: https://npmjs.org/package/ml-logistic-regression
41-
[travis-image]: https://img.shields.io/travis/mljs/logistic-regression/master.svg?style=flat-square
42-
[travis-url]: https://travis-ci.org/mljs/logistic-regression
43-
[download-image]: https://img.shields.io/npm/dm/ml-logistic-regression.svg?style=flat-square
53+
[ci-image]: https://github.com/mljs/logistic-regression/workflows/Node.js%20CI/badge.svg?branch=master
54+
[ci-url]: https://github.com/mljs/logistic-regression/actions?query=workflow%3A%22Node.js+CI%22
55+
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/logistic-regression.svg
56+
[codecov-url]: https://codecov.io/gh/mljs/logistic-regression
57+
[download-image]: https://img.shields.io/npm/dm/ml-logistic-regression.svg
4458
[download-url]: https://npmjs.org/package/ml-logistic-regression

__tests__/test.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
plugins: ['@babel/plugin-transform-modules-commonjs'],
3+
};

0 commit comments

Comments
 (0)