Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/retraigo/appraisal

Machine Learning utilities for TypeScript
https://github.com/retraigo/appraisal

encoding machine-learning nlp tf-idf typescript

Last synced: 2 months ago
JSON representation

Machine Learning utilities for TypeScript

Awesome Lists containing this project

README

        

# Appraisal

- Machine Learning utilities for TypeScript.

## Modules
- [Text Vectorizer](/src/text)
- [Image](/src/image)
- [Metrics](/src/metrics)

## Example: Text

```ts
const data = [
"twinkle twinkle little star",
"How I wonder what you are",
"up above the world so high",
"like a diamond in the sky",
];

// Clean the text
const cleaner = new TextCleaner({
lowercase: true,
stripHtml: true,
stripNewlines: true,
normalizeWhiteSpaces: true,
});
x = cleaner.clean(x);

// Tokenize the text
const tokenizer = new SplitTokenizer();
tokenizer.fit(x);
const x_tokens = tokenizer.transform(x);

// Vectorize the tokens
const vectorizer = new CountVectorizer(tokenizer.vocabulary.size);
const x_vec = vectorizer.transform(x_tokens, "f32");

// Apply Tf-Idf transformation
const transformer = new TfIdfTransformer();
console.log(transformer.fit(x_vec).transform(x_vec));

```