# @types/ml-classify-text

> TypeScript definitions for ml-classify-text

Latest version **2.0.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/ml-classify-text
pnpm add @types/ml-classify-text
yarn add @types/ml-classify-text
bun add @types/ml-classify-text
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2023-11-07 |
| First published | 2022-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51439 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/ml-classify-text
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ml-classify-text
- npm.io page: https://npm.io/package/@types/ml-classify-text

## Recent versions

- 2.0.3 (latest) — 2023-11-07
- 2.0.0 (ts4.3) — 2022-10-05
- 2.0.2 — 2023-10-18
- 2.0.1 — 2023-09-27

## README

# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ml-classify-text/index.d.ts)
````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](https://github.com/promise).

---
_Source: https://npm.io/package/@types/ml-classify-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
