|
1 | 1 | # jsonstack-math
|
2 |
| -math, matrix and other helpers |
| 2 | +linear algebra, math, matrix and other helpers |
3 | 3 |
|
| 4 | +# JSONSTACK Math |
| 5 | + [](https://coveralls.io/github/repetere/jsonstack-math?branch=main) [](https://github.com/repetere/jsonstack-math/actions/workflows/release.yml) |
| 6 | + |
| 7 | +## Description |
| 8 | + |
| 9 | +**JSONSTACK Math** is a module that ...WIP. |
| 10 | + |
| 11 | +### Jump right in |
| 12 | + |
| 13 | +... is designed so software engineers and machine learning engineers can ...WIP. |
| 14 | + |
| 15 | +### Usage |
| 16 | + |
| 17 | +The idea behind ... WIP. |
| 18 | + |
| 19 | +### What's included |
| 20 | +...WIP... |
| 21 | + - tbd |
| 22 | + - tbd |
| 23 | +## Installation |
| 24 | + |
| 25 | +```sh |
| 26 | +$ npm i @jsonstack/math |
| 27 | +``` |
| 28 | + |
| 29 | +< link id= "viewx-style-style-0" rel= "stylesheet" type= "text/css" href= "https://unpkg.com/[email protected]/styles/darkula.css"> |
| 30 | + |
| 31 | +--- |
| 32 | +### jsonstack-math Manual |
| 33 | + - [Getting Started](https://repetere.github.io/jsonstack-math/manual/getting-started/index.html) |
| 34 | + - Working With Data |
| 35 | + - [Data Fetching](https://repetere.github.io/jsonstack-math/manual/data-fetching/index.html) |
| 36 | + - [Feature Engineering](https://repetere.github.io/jsonstack-math/manual/feature-engineering/index.html) |
| 37 | + - Working With Models |
| 38 | + - [Model Training](https://repetere.github.io/jsonstack-math/manual/model-training/index.html) |
| 39 | + - [Model Evaluation](https://repetere.github.io/jsonstack-math/manual/model-evaluation/index.html) |
| 40 | + - [Model Predictions](https://repetere.github.io/jsonstack-math/manual/model-predictions/index.html) |
| 41 | + - [Saving and Loading Models](https://repetere.github.io/jsonstack-math/manual/saving-and-loading-models/index.html) |
| 42 | + - [Advanced Topics](https://repetere.github.io/jsonstack-math/manual/advanced-topics/index.html) |
| 43 | + - [jsonstack-math & JML Spec](https://repetere.github.io/jsonstack-math/manual/spec/index.html) |
| 44 | + - [Examples](https://repetere.github.io/jsonstack-math/manual/examples/index.html) |
| 45 | + - [Full API Docs](https://repetere.github.io/jsonstack-math/) |
| 46 | +--- |
| 47 | + |
| 48 | +### Basic Usage |
| 49 | +```typescript |
| 50 | +import * as tf from '@tensorflow/tfjs-node'; |
| 51 | +import { getModel, setBackend, } from '@jsonstack/jsonstack-math'; |
| 52 | + |
| 53 | +//set tensorflow |
| 54 | +setBackend(tf); |
| 55 | + |
| 56 | +//Iris Dataset e.g from https://raw.githubusercontent.com/repetere/modelx-model/master/src/test/mock/data/iris_data.csv |
| 57 | +const type = 'ai-classification'; |
| 58 | +const dataset = [ |
| 59 | + { |
| 60 | + "sepal_length_cm": 5.1, |
| 61 | + "sepal_width_cm": 3.5, |
| 62 | + "petal_length_cm": 1.4, |
| 63 | + "petal_width_cm": 0.2, |
| 64 | + "plant": "Iris-setosa", |
| 65 | + }, |
| 66 | +// ... |
| 67 | + { |
| 68 | + "sepal_length_cm": 7.0, |
| 69 | + "sepal_width_cm": 3.2, |
| 70 | + "petal_length_cm": 4.7, |
| 71 | + "petal_width_cm": 1.4, |
| 72 | + "plant": "Iris-versicolor", |
| 73 | + }, |
| 74 | + // ... |
| 75 | + { |
| 76 | + "sepal_length_cm": 5.9, |
| 77 | + "sepal_width_cm": 3.0, |
| 78 | + "petal_length_cm": 5.1, |
| 79 | + "petal_width_cm": 1.8, |
| 80 | + "plant": "virginica", |
| 81 | + } |
| 82 | +] |
| 83 | +const inputs = ['sepal_length_cm','sepal_width_cm','petal_length_cm','petal_width_cm', ]; |
| 84 | +const outputs = [ 'plant',]; |
| 85 | +const on_progress = ({ completion_percentage, loss, epoch, status, logs, defaultLog, }) => { |
| 86 | + console.log({ completion_percentage, loss, epoch, status, logs, defaultLog, }); |
| 87 | +} |
| 88 | +const IrisModel = await getModel({ |
| 89 | + type, |
| 90 | + dataset, |
| 91 | + inputs, |
| 92 | + outputs, |
| 93 | + on_progress, |
| 94 | +}); |
| 95 | +await IrisModel.trainModel() |
| 96 | +const predictions = await IrisModel.predictModel({ |
| 97 | + prediction_inputs:[ |
| 98 | + { sepal_length_cm: 5.1, sepal_width_cm: 3.5, petal_length_cm: 1.4, petal_width_cm: 0.2, }, |
| 99 | + { sepal_length_cm: 5.9, sepal_width_cm: 3.0, petal_length_cm: 5.1, petal_width_cm: 1.8, }, |
| 100 | + ], |
| 101 | +}); // => [ { plant:'Iris-setosa' }, { plant:'Iris-virginica' }, ] |
| 102 | + |
| 103 | +``` |
| 104 | + |
| 105 | +## Example ## |
| 106 | +<iframe width="100%" height="500" src="https://jsfiddle.net/yawetse/4ph1vwes/21/embedded/result,js,html,css,resources/dark/" allowfullscreen="allowfullscreen" allowpaymentrequest frameborder="0"></iframe> |
| 107 | + |
| 108 | +### Development |
| 109 | + |
| 110 | +Note *Make sure you have typescript installed* |
| 111 | + |
| 112 | +```sh |
| 113 | +$ npm i -g typescript |
| 114 | +``` |
| 115 | + |
| 116 | +For generating documentation |
| 117 | + |
| 118 | +```sh |
| 119 | +$ npm run doc |
| 120 | +``` |
| 121 | + |
| 122 | +### Notes |
| 123 | + |
| 124 | +Check out [https://repetere.github.io/jsonstack-math/](https://repetere.github.io/jsonstack-math/) for the full jsonstack-math Documentation |
| 125 | + |
| 126 | +### Testing |
| 127 | + |
| 128 | +```sh |
| 129 | +$ npm test |
| 130 | +``` |
| 131 | + |
| 132 | +### Contributing |
| 133 | + |
| 134 | +Fork, write tests and create a pull request! |
| 135 | + |
| 136 | +License |
| 137 | + |
| 138 | +---- |
| 139 | + |
| 140 | +MIT |
0 commit comments