Home Reference Source Test

Function

Static Public Summary
public

assocationRuleLearning(transactions: Array, options: Object): Object

returns association rule learning results

public

getTransactions(data: Array, options: Object): Object

Formats an array of transactions into a sparse matrix like format for Apriori/Eclat

public

async loadCSV(filepath: string, options: Object): Object[]

Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects

public

async loadCSVURI(filepath: string, options: Object): Object[]

Asynchronously loads a CSV from a remote URL and returns an array of objects

public

async loadTSV(filepath: string, options: Object): Object[]

Asynchronously loads a TSV from either a filepath or remote URL and returns an array of objects

Static Public

public assocationRuleLearning(transactions: Array, options: Object): Object source

import {assocationRuleLearning} from 'modelscript/src/calc.mjs'

returns association rule learning results

Params:

NameTypeAttributeDescription
transactions Array

sparse matrix of transactions

options Object
options.support Number
  • optional
  • default: 0.4

support level

options.minLength Number
  • optional
  • default: 2

minimum assocation array size

options.summary Boolean
  • optional
  • default: true

return summarized results

options.valuesMap Map
  • optional
  • default: new Map()

map of values and labels (used for summary results)

Return:

Object

Returns the result from Node-FPGrowth or a summary of support and strong associations

See:

  • https://github.com/alexisfacques/Node-FPGrowth

public getTransactions(data: Array, options: Object): Object source

import {getTransactions} from 'modelscript/src/calc.mjs'

Formats an array of transactions into a sparse matrix like format for Apriori/Eclat

Params:

NameTypeAttributeDescription
data Array

CSV data of transactions

options Object
options.exludeEmptyTranscations Boolean
  • optional
  • default: true

exclude empty rows of transactions

Return:

Object

{values - unique list of all values, valuesMap - map of values and labels, transactions - formatted sparse array}

See:

  • https://github.com/alexisfacques/Node-FPGrowth

public async loadCSV(filepath: string, options: Object): Object[] source

import {loadCSV} from 'modelscript/src/csv.mjs'

Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects

Params:

NameTypeAttributeDescription
filepath string

URL to CSV path

options Object
  • optional

options passed to csvtojson

Return:

Object[]

returns an array of objects from a csv where each column header is the property name

Example:

// returns [{header:value,header2:value2}]
loadCSV('../mock/invalid-file.csv').then(csvData).catch(console.error)

public async loadCSVURI(filepath: string, options: Object): Object[] source

import {loadCSVURI} from 'modelscript/src/csv.mjs'

Asynchronously loads a CSV from a remote URL and returns an array of objects

Params:

NameTypeAttributeDescription
filepath string

URL to CSV path

options Object
  • optional

options passed to csvtojson

Return:

Object[]

returns an array of objects from a csv where each column header is the property name

Example:

// returns [{header:value,header2:value2}]
loadCSVURI('https://raw.githubusercontent.com/repetere/modelscript/master/test/mock/data.csv').then(csvData).catch(console.error)

public async loadTSV(filepath: string, options: Object): Object[] source

import {loadTSV} from 'modelscript/src/csv.mjs'

Asynchronously loads a TSV from either a filepath or remote URL and returns an array of objects

Params:

NameTypeAttributeDescription
filepath string

URL to CSV path

options Object
  • optional

options passed to csvtojson

Return:

Object[]

returns an array of objects from a csv where each column header is the property name

Example:

// returns [{header:value,header2:value2}]
loadCSV('../mock/invalid-file.tsv').then(csvData).catch(console.error)