Class ModelAbstract

An abstract class to represent a model that we can train from a DataTraining instance. This model is originally meant to be used as a classifier. There are two main implementations : RandomForestModel for Random Forest and TensorFlowModel for Neural Networks.
You can extend this class to create a brand-new classifier architecture.

Hierarchy

Constructors

Properties

batchSize: number
consoleInfo: boolean
epoch: number
nameToLoad: string
nameToSave: string
useTfjsVis: boolean

Methods

  • Gets a sample of test data and returns the model output, with some basic operations to reshape the output as 1d tensor.

    Returns

    A list of two elements that are 1d tensors corresponding to a list [b1, b2, ...]. These two list are 0-1 lists for each batch element to be a bot trajectory (1 means bot).

    Parameters

    • size: number

      The batch size for the sample.

    Returns Tensor1D[]

  • Get prediction and labels and return the accuracy per class.

    Parameters

    • predicts: Tensor1D

      The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).

    • labels: Tensor1D

      The true labels, 1d tensor of 0 or 1.

    Returns Promise<{
        accuracy: number;
        count: number;
    }[]>

  • Get prediction and labels and return the confusion matrix.

    Parameters

    • predicts: Tensor1D

      The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).

    • labels: Tensor1D

      The true labels, 1d tensor of 0 or 1.

    Returns Promise<number[][]>

  • Run the entire model logic, including loading (if nameToLoad is not null), load all data, train the model, save it (if nameToSave is not null), test it and show all additional information with tfjs-vis or in the console.

    Returns any

  • Get the model prediction batch and its corresponding labels as 1D tensors and show with tfjs-vis or in console (according to useTfjsVis and consoleInfo) the accuracy of each class and the confusion matrix.

    Parameters

    • predicts: Tensor1D

      The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).

    • labels: Tensor1D

      The true labels, 1d tensor of 0 or 1.

    • name: string = "validation"

      Default to "validation", used in the container name of tfjs-vis.

    Returns Promise<void>

Generated using TypeDoc