Preprocessing utilities for machine learning in Starlight
npm install starlight-preprocessstarlight-regression, starlight-classifier, starlight-cluster
starlight-pipeline
bash
npm install starlight-preprocess
`
---
Usage Examples
$3
`js
import { StandardScaler } from "starlight-preprocess";
const X = [
[1, 10],
[2, 20],
[3, 30]
];
const scaler = new StandardScaler();
const XScaled = scaler.fitTransform(X);
console.log(XScaled);
`
---
$3
`js
import { MinMaxScaler } from "starlight-preprocess";
const scaler = new MinMaxScaler();
const normalized = scaler.fitTransform(X);
`
---
$3
`js
import { LabelEncoder } from "starlight-preprocess";
const labels = ["cat", "dog", "cat", "bird"];
const encoder = new LabelEncoder();
const encoded = encoder.fitTransform(labels);
console.log(encoded);
// [0, 1, 0, 2]
`
---
$3
`js
import { OneHotEncoder } from "starlight-preprocess";
const encoder = new OneHotEncoder();
const oneHot = encoder.fitTransform(["red", "blue", "red"]);
console.log(oneHot);
// [[1,0],[0,1],[1,0]]
`
---
$3
`js
import { trainTestSplit } from "starlight-preprocess";
const X = [[1], [2], [3], [4], [5]];
const y = [2, 4, 6, 8, 10];
const { XTrain, XTest, yTrain, yTest } =
trainTestSplit(X, y, 0.2);
console.log(XTrain, XTest);
`
---
API Overview
$3
* StandardScaler
* MinMaxScaler
Methods
* fit(X)
* transform(X)
* fitTransform(X)
---
$3
* LabelEncoder
* OneHotEncoder
Methods
* fit(values)
* transform(values)
* fitTransform(values)
inverseTransform() (LabelEncoder)*
---
$3
* trainTestSplit(X, y, testSize = 0.2, shuffle = true)
---
Works Great With
* starlight-ml
* starlight-vec
* starlight-classifier
* starlight-regression
* starlight-cluster
* starlight-pipeline`