ml-basic
Version:
Lightweight, zero dependency, machine learning library
54 lines (53 loc) • 1.55 kB
TypeScript
import Matrix from "./matrix";
declare const inputKeys: readonly ["input", "in"];
declare const targetKeys: readonly ["target", "output", "out", "label"];
type InputValue = number[] | number | undefined | null;
type TargetValue = InputValue | string;
type InputKeys = typeof inputKeys[number];
type TargetKeys = typeof targetKeys[number];
export type DataEntry = {
[key in InputKeys | TargetKeys]?: key extends InputKeys ? InputValue : TargetValue;
};
type InputData = DataEntry[] | InputValue[];
type TargetData = DataEntry[] | TargetValue[];
export default class DataFrame {
data: {
input: Matrix;
target: Matrix;
}[];
labels: Map<string, number>;
size: {
input: number;
target: number;
};
constructor(raw: InputData);
constructor(input: InputData, target: TargetData);
private isValue;
private toValue;
private getKey;
private getLength;
getLabels(): string[];
clean({ missing, duplicates, uneven }?: {
missing?: 'remove' | 'zero';
duplicates?: 'remove' | 'keep';
uneven?: 'remove' | 'pad';
}): this;
normalize({ mode, min, max }?: {
/**
* @default 'target'
*/
mode?: 'target' | 'input' | 'both';
/**
* @default 0
*/
min?: number;
/**
* @default 1
*/
max?: number;
}): this;
split(divide?: number): DataFrame[];
static from(file: string | Blob): Promise<DataFrame>;
save(file: string): void;
}
export {};