UNPKG

datamagic-ml

Version:

A lightweight JavaScript library for essential feature engineering tasks in machine learning. Provides utilities for normalization, standardization, one-hot encoding and missing value handling. Designed for simplicity and performance in both Node.js and b

13 lines (11 loc) 282 B
class OneHotEncoder { fit(data) { this.categories = [...new Set(data)]; } transform(data) { return data.map(value => this.categories.map(category => (category === value ? 1 : 0)) ); } } module.exports = OneHotEncoder;