@types/ml-classify-text
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Installation

npm install --save @types/ml-classify-text

Summary

This package contains type definitions for ml-classify-text (https://github.com/andreekeberg/ml-classify-text-js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ml-classify-text.

index.d.ts

interface ModelOptions {
    nGramMin: number;
    nGramMax: number;
    vocabulary: string[];
    data: {};
}

interface PredictionOptions {
    label: string;
    confidence: number;
}

declare class Classifier {
    constructor(model?: Partial<ModelOptions> | Model);
    get model(): Model;
    set model(model: Model | Partial<ModelOptions>);
    train(input: string | string[], label: string): this;
    predict(input: string, maxMatches?: number, minimumConfidence?: number): Prediction[];
    splitWords(input: string): string[];
    tokenize(input: string | string[]): Record<string, number>;
    vectorize(tokens: Record<string, number>): Record<number, number>;
    cosineSimilarity(v1: Record<number, number>, v2: Record<number, number>): number;
}

declare class Model {
    constructor(config?: Partial<ModelOptions>);
    get nGramMin(): number;
    set nGramMin(nGramMin: number);
    get nGramMax(): number;
    set nGramMax(nGramMax: number);
    get vocabulary(): Vocabulary;
    set vocabulary(vocabulary: Vocabulary | string[]);
    get data(): Record<string, Record<string, number>>;
    set data(data: Record<string, Record<string, number>>);
    serialize(): ModelOptions;
}

declare class Vocabulary {
    constructor(terms: string[]);
    get size(): number;
    get terms(): Set<string>;
    set terms(terms: Set<string> | string[]);
    add(terms: string | string[] | Set<string>): this;
    remove(terms: string | string[] | Set<string>): this;
    has(term: string): boolean;
    indexOf(term: string): number;
}

declare class Prediction {
    constructor(prediction?: Partial<PredictionOptions>);
    get label(): string;
    set label(label: string);
    get confidence(): number;
    set confidence(confidence: number);
}

export {
    Classifier,
    Classifier as default,
    Model,
    Vocabulary as Cocabulary, // typo by the package author
};

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: none

Credits

These definitions were written by Glenn.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/ml-classify-text

Weekly Downloads

39

Version

2.0.3

License

MIT

Unpacked Size

6.35 kB

Total Files

5

Last publish

Collaborators

  • types