Orchestrate ML pipelines. One design different to sklearn
pipelines is that our transformers can have the attribute onTarget
for use in Pipelines. There, it can be convenient and to simply add a target transformation as a step into the Pipeline
$ npm i ml-pipe
import { trainTestSplit } from 'ml-pipe/modelSelection/trainTestSplit';
import {Pipeline} from 'ml-pipe/pipeline';
import {FCNN} from 'ml-pipe/estimators/neuralNetwork/fcnn'
import {StandardScaler, TargetStandardScaler} from 'ml-pipe/transformers/preprocessing/standardScaler'
import {meanSquaredError} from 'ml-pipe/metrics/regression'
const {xTrain, xTest, yTrain, yTest} = trainTestSplit(x, y,
{trainFraction: 0.8, stratify: yBinned})
const pipe = new Pipeline([
('xScale', new StandardScaler()),
('yScale', new TargetStandardScaler()),
('model', new FCNN({inputSize: 5}))
])
await pipe.fit(XTrain, yTrain)
const predictionsTest = pipe.predict(xTest)
const mse = meanSquaredError(predictionsTest, yTest)