-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: need still to convert to typescript
- Loading branch information
Showing
16 changed files
with
526 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extends: cheminfo-typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
nodejs: | ||
# Documentation: https://github.com/zakodium/workflows#nodejs-ci | ||
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1 | ||
with: | ||
lint-check-types: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
# Documentation: https://github.com/zakodium/workflows#release | ||
uses: zakodium/workflows/.github/workflows/release.yml@release-v1 | ||
with: | ||
npm: true | ||
secrets: | ||
github-token: ${{ secrets.BOT_TOKEN }} | ||
npm-token: ${{ secrets.NPM_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Deploy TypeDoc on GitHub pages | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
NODE_VERSION: 18.x | ||
ENTRY_FILE: 'src/index.ts' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Build documentation | ||
uses: zakodium/typedoc-action@v2 | ||
with: | ||
entry: ${{ env.ENTRY_FILE }} | ||
- name: Deploy to GitHub pages | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
token: ${{ secrets.BOT_TOKEN }} | ||
branch: gh-pages | ||
folder: docs | ||
clean: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
lib | ||
|
||
lib-esm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"arrowParens": "always", | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# regression-polynomial-2d | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![npm download][download-image]][download-url] | ||
[![build status][ci-image]][ci-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
|
||
Polynomial Regression. | ||
|
||
## Installation | ||
|
||
`$ npm i ml-regression-polynomial-2d` | ||
|
||
## Usage | ||
|
||
```js | ||
import { PolynomialRegression } from 'ml-regression-polynomial-2d'; | ||
|
||
const x = [50, 50, 50, 70, 70, 70, 80, 80, 80, 90, 90, 90, 100, 100, 100]; | ||
const y = [ | ||
3.3, 2.8, 2.9, 2.3, 2.6, 2.1, 2.5, 2.9, 2.4, 3.0, 3.1, 2.8, 3.3, 3.5, 3.0, | ||
]; | ||
const degree = 5; // setup the maximum degree of the polynomial | ||
|
||
const regression = new PolynomialRegression(x, y, degree); | ||
|
||
console.log(regression.predict(80)); // Apply the model to some x value. Prints 2.6. | ||
console.log(regression.coefficients); // Prints the coefficients in increasing order of power (from 0 to degree). | ||
console.log(regression.toString(3)); // Prints a human-readable version of the function. | ||
console.log(regression.toLaTeX()); | ||
console.log(regression.score(x, y)); | ||
``` | ||
|
||
## Options | ||
|
||
An `interceptAtZero` option is available, to force $f(0) = 0$. Also, a "powers array" can be specified. | ||
|
||
- Using `interceptAtZero` | ||
|
||
```js | ||
const regression = new PolynomialRegression(x, y, degree, { | ||
interceptAtZero: true, | ||
}); | ||
``` | ||
|
||
- Using the powers array | ||
|
||
```js | ||
const powers = [0, 1, 2, 3, 4, 5]; | ||
const regression = new PolynomialRegression(x, y, powers); | ||
``` | ||
|
||
`powers` could also be `[1,2,3,4,5]`or`[1,3,5]` and so on. | ||
|
||
For intercepting at zero using an array, skip the zero in the array (the option `interceptAtZero` is ignored in this case.) | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/ml-regression-polynomial-2d.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/ml-regression-polynomial-2d | ||
[download-image]: https://img.shields.io/npm/dm/ml-regression-polynomial-2d.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/ml-regression-polynomial-2d | ||
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/regression-polynomial-2d.svg | ||
[codecov-url]: https://codecov.io/gh/mljs/regression-polynomial-2d | ||
[ci-image]: https://github.com/mljs/regression-polynomial-2d/workflows/Node.js%20CI/badge.svg?branch=main | ||
[ci-url]: https://github.com/mljs/regression-polynomial-2d/actions?query=workflow%3A%22Node.js+CI%22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "ml-regression-polynomial-2d-2d", | ||
"version": "0.0.0", | ||
"description": "Polynomial Regression 2D", | ||
"types": "./lib/index.d.ts", | ||
"main": "./lib/index.js", | ||
"module": "./lib-esm/index.js", | ||
"files": [ | ||
"src", | ||
"lib", | ||
"lib-esm" | ||
], | ||
"scripts": { | ||
"check-types": "tsc --noEmit", | ||
"clean": "rimraf lib lib-esm", | ||
"eslint": "eslint src", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
"prepack": "npm run tsc", | ||
"prettier": "prettier --check src", | ||
"prettier-write": "prettier --write src", | ||
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types", | ||
"test-only": "vitest run --coverage", | ||
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm", | ||
"tsc-cjs": "tsc --project tsconfig.cjs.json", | ||
"tsc-esm": "tsc --project tsconfig.esm.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/mljs/regression-polynomial-2d.git" | ||
}, | ||
"keywords": [], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mljs/regression-polynomial-2d/issues" | ||
}, | ||
"homepage": "https://github.com/mljs/regression-polynomial-2d#readme", | ||
"devDependencies": { | ||
"@vitest/coverage-v8": "^1.2.2", | ||
"eslint": "^8.56.0", | ||
"eslint-config-cheminfo-typescript": "^12.1.0", | ||
"ml-spectra-processing": "^12.10.1", | ||
"prettier": "^3.2.4", | ||
"rimraf": "^5.0.5", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.2.2" | ||
}, | ||
"dependencies": { | ||
"cheminfo-types": "^1.7.2", | ||
"ml-matrix": "^6.11.0", | ||
"ml-regression-base": "^3.0.0" | ||
} | ||
} |
Oops, something went wrong.