class creating sparse matrices from a corpus

memberof

  nlp

### Hierarchy

- ColumnVectorizer

## Index

### Constructors

- constructor

### Properties

- data
- limitedFeatures
- matrix
- maxFeatures
- replacer
- sortedWordCount
- tokens
- vectors
- wordCountMap
- wordMap

### Methods

- evaluate
- evaluateString
- fit_transform
- get_limited_features
- get_tokens
- get_vector_array

## Constructors

### constructor

- new ColumnVectorizer(options?: { data?: string[]; maxFeatures?: undefined | number }): ColumnVectorizer

- - Defined in ColumnVectorizer.ts:28

  creates a new instance for classifying text data for machine learning

  example

    const dataset = new ms.nlp.ColumnVectorizer(csvData);

  prop

    {Object[]} this.data - Array of strings

  prop

    {Set} this.tokens - Unique collection of all tokenized strings

  prop

    {Object[]} this.vectors - Array of tokenized words with value of count of appreance in string

  prop

    {Object} this.wordMap - Object of all unique words, with value of 0

  prop

    {Object} this.wordCountMap - Object of all unique words, with value as total count of appearances

  prop

    {number} this.maxFeatures - max number of features

  prop

    {String[]} this.sortedWordCount - list of words as tokens sorted by total appearances

  prop

    {String[]} this.limitedFeatures - subset list of maxFeatures words as tokens sorted by total appearances

  prop

    {Array[]} this.matrix - words in sparse matrix

  prop

    {Function} this.replacer - clean string function

  #### Parameters

  - ##### Default value options: { data?: string[]; maxFeatures?: undefined | number } = {}

    - ##### Optional data?: string[]

    - ##### Optional maxFeatures?: undefined | number

  #### Returns ColumnVectorizer

## Properties

### data

data: string[]

- Defined in ColumnVectorizer.ts:19

### limitedFeatures

limitedFeatures: string[][]

- Defined in ColumnVectorizer.ts:26

### matrix

matrix: Matrix

- Defined in ColumnVectorizer.ts:27

### Optional maxFeatures

maxFeatures: undefined | number

- Defined in ColumnVectorizer.ts:24

### replacer

replacer: (value: string) => string

- Defined in ColumnVectorizer.ts:28

#### Type declaration

- - (value: string): string

  - #### Parameters

    - ##### value: string

    #### Returns string

### sortedWordCount

sortedWordCount: string[]

- Defined in ColumnVectorizer.ts:25

### tokens

tokens: Set<string>

- Defined in ColumnVectorizer.ts:20

### vectors

vectors: WordMap[]

- Defined in ColumnVectorizer.ts:21

### wordCountMap

wordCountMap: WordMap

- Defined in ColumnVectorizer.ts:23

### wordMap

wordMap: WordMap

- Defined in ColumnVectorizer.ts:22

## Methods

### evaluate

- evaluate(testString?: string, options: { maxFeatures?: undefined | number }): any

- - Defined in ColumnVectorizer.ts:190

  returns new matrix of words with counts in columns

  example

    ColumnVectorizer.evaluate('I would rate everything Great, views Great, food Great') => [ [ 0, 1, 3, 0, 0, 0, 0, 0, 1 ] ]

  #### Parameters

  - ##### Default value testString: string = ""

  - ##### options: { maxFeatures?: undefined | number }

    - ##### Optional maxFeatures?: undefined | number

  #### Returns any

  sparse matrix row for new classification predictions

### evaluateString

- evaluateString(testString?: string): WordMap

- - Defined in ColumnVectorizer.ts:167

  returns word map with counts

  example

    ColumnVectorizer.evaluateString('I would rate everything Great, views Great, food Great') => { realli: 0, good: 0, definit: 0, recommend: 0, wait: 0, staff: 0, rude: 0, great: 3, view: 1, food: 1, not: 0, cold: 0, took: 0, forev: 0, seat: 0, time: 0, prompt: 0, attent: 0, bland: 0, flavor: 0, kind: 0 }

  #### Parameters

  - ##### Default value testString: string = ""

  #### Returns WordMap

  object of corpus words with accounts

### fit_transform

- fit_transform(options?: { data?: string[]; maxFeatures?: undefined | number }): number[][]

- - Defined in ColumnVectorizer.ts:97

  Fits and transforms data by creating column vectors (a sparse matrix where each row has every word in the corpus as a column and the count of appearances in the corpus)

  #### Parameters

  - ##### Default value options: { data?: string[]; maxFeatures?: undefined | number } = {}

    - ##### Optional data?: string[]

      array of corpus data

    - ##### Optional maxFeatures?: undefined | number

  #### Returns number[][]

### get_limited_features

- get_limited_features(options?: { maxFeatures?: undefined | number }): string[][]

- - Defined in ColumnVectorizer.ts:133

  Returns limited sets of dependent features or all dependent features sorted by word count

  #### Parameters

  - ##### Default value options: { maxFeatures?: undefined | number } = {}

    - ##### Optional maxFeatures?: undefined | number

      max number of features

  #### Returns string[][]

### get_tokens

- get_tokens(): string[]

- - Defined in ColumnVectorizer.ts:80

  Returns a distinct array of all tokens

  #### Returns string[]

  returns a distinct array of all tokens

### get_vector_array

- get_vector_array(): string[][]

- - Defined in ColumnVectorizer.ts:87

  Returns array of arrays of strings for dependent features from sparse matrix word map

  #### Returns string[][]

  returns array of dependent features for DataSet column matrics