Package Exports
- datamagic-ml
- datamagic-ml/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (datamagic-ml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DataMagic-ML
A lightweight JavaScript library for essential feature engineering tasks. Provides utilities for normalization, standardization, one-hot encoding, and missing value handling. Designed for simplicity and performance in both Node.js and browser environments.
Features
- Min-Max Scaling: Normalize data to a specific range.
- Standardization: Transform data to have zero mean and unit variance.
- One-Hot Encoding: Convert categorical data into numerical format.
- Missing Value Handling: Replace missing values with mean, median, or a constant.
Installation
You can install datamagic-ml via npm:
npm install datamagic-mlOr using yarn:
yarn add datamagic-mlUsage
Importing the Library:
const { MinMaxScaler, StandardScaler, OneHotEncoder, CleanMissings } = require('datamagic-ml');Min-Max Scaling
const scaler = new MinMaxScaler();
const data = [1, 2, 3, 4, 5];
scaler.fit(data);
console.log(scaler.transform(data));Standardization
const stdScaler = new StandardScaler();
const data = [1, 2, 3, 4, 5];
stdScaler.fit(data);
console.log(stdScaler.transform(data));One-Hot Encoding
const encoder = new OneHotEncoder();
encoder.fit(['red', 'green', 'blue']);
console.log(encoder.transform(['green', 'red', 'yellow', 'blue'])); Handling Missing Values
const testArray = [1, null, 3, 4, NaN, 6];
console.log(CleanMissings(testArray, 'mean'));
console.log(CleanMissings(testArray, 'median'));
console.log(CleanMissings(testArray, 'constant', 0));License
Licensed under the MIT License.