JSONM Manual
- Getting Started
- Working With Data
- Working With Models
- Advanced Topics
Getting started
JSONM is a library that creates Tensorflow models from JSON. JSONM works by converting JSON Objects that follow the JML JSON spec into a Tensorflow model that can be trained, evaluated and used to make predictions.
JSONM can normalize, scale, feature engineer inputs and outputs automatically. You can also specify how JSONM creates your model for you.
A simple linear regression example
import {getModel} from '@jsonstack/jsonm';
const inputs = ['height',];
const outputs = [ 'weight',];
function on_progress({ completion_percentage, loss, epoch, status, }){
console.log({ completion_percentage, loss, epoch, status, })
}
const exampleJSON: JML = {
type: 'regression',
inputs,
outputs,
on_progress,
dataset:[
{height:61, weight:105},
{height:62, weight:120},
{height:63, weight:120},
{height:65, weight:160},
{height:65, weight:120},
{height:68, weight:145},
{height:69, weight:175},
{height:70, weight:160},
{height:72, weight:185},
{height:75, weight:210},
]
}
const simpleModel = await getModel(exampleJSON);
await simpleModel.trainModel()
const predictions = await simpleModel.predictModel(
[
{ height: 60, },
{ height: 71, },
{ height: 80, },
],
);
/*
=> predictions: [
{ weight: 99.99914637982626, height: 60 },
{ weight: 177.6612194038534, height: 71 },
{ weight: 241.20291735639228, height: 80 }
]
*/
Usages
JSONM is great for
- Adding TensorFlow models to JAMStack based applications
- Quickly building models directly in the browser or Node.js
- Serving previously trained Tensorflow models
JSONM is not great for
- A heavy exploratory analysis
Example
How JSONM works
JSONM works by translating a JSON object that follows the JML spec into a tensorflow model using both @jsonstack/data and @jsonstack/model.
@jsonstack/data
The jsonstack data module is a library that constructs datasets for machine learning models. @jsonstack/data contains methods for preprocessing and feature engineering data. You can find out more about how @jsonstack/data works from the documentation. JSONM can be used to automate preprocessing and feature engineering for you.
@jsonstack/model
The jsonstack model module is a library that constructs tensorflow models for machine learning models. @jsonstack/model contains classes for various kinds of machine learning and artifical intelligence models. You can find out more about how @jsonstack/model works from the documentation. JSONM can be used to automatically define, train and evaluate tensorflow models for you.
Declarative vs Imperative Models
The primary way to build a Tensorflow model JSONM is to use the declarative model description via a JSON object that follows the JML spec. In some instances if you need to finely control how your models are trained and evaluated, the JSONModel Class is how models are created and can be used to manually create models.
Read more about manual model creation in Advanced Topics.
Next: Data Fetching
JSONM Manual
- Getting Started
- Working With Data
- Working With Models
- Advanced Topics