io.siddhi.extension.execution.streamingml.bayesian.util

## Class BayesianModel

- java.lang.Object
- - io.siddhi.extension.execution.streamingml.bayesian.util.BayesianModel

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    LinearRegression, SoftmaxRegression

      public abstract class BayesianModel
      extends Object
      implements Serializable

  model interface.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BayesianModel.OptimizerType` optimizer types that can be used with the bayesian models.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract double` | `evaluate(double[] features, Object expected)`
    `double` | `getLearningRate()`
    `int` | `getNumFeatures()`
    `int` | `getNumSamples()`
    `BayesianModel.OptimizerType` | `getOptimizerType()`
    `protected abstract double[][]` | `getUpdatedWeights()` implements the model specific gradient updates.
    `void` | `initiateModel()` construct the model.
    `Double` | `predict(double[] features)` predict the target according to given features.
    `Double[]` | `predictWithStd(double[] features)` predict the target according to given features.
    `void` | `setAddBias(boolean val)`
    `void` | `setLearningRate(double val)`
    `void` | `setNumFeatures(int val)`
    `void` | `setNumSamples(int val)`
    `void` | `setOptimizerType(BayesianModel.OptimizerType val)`
    `void` | `setPredictionSamples(int val)`
    `double[]` | `update(double[] features, double[] target)` train the model.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### initiateModel

          public void initiateModel()

      construct the model.

    - #### update

          public double[] update(double[] features,
                                 double[] target)

      train the model.
      Parameters:
        `features` - feature vector
        `target` - target/label for regression target should be a real vector for binary classification target should be a vector with labels (0 or 1) multiclass classification expects one-hot embedded matrix or a vector with label indexes

    - #### predict

          public Double predict(double[] features)

      predict the target according to given features. predictive distribution is approximated using nSamples from the actual distribution

      uses 1000 (default) samples to estimate the predictive distribution

      Parameters:
        `features` - feature vector
      Returns:
        only the mean of the predictions

    - #### predictWithStd

          public Double[] predictWithStd(double[] features)

      predict the target according to given features. predictive distribution is approximated using nSamples from the actual distribution

      uses 1000 (default) samples to estimate the predictive distribution

      Parameters:
        `features` - feature vector
      Returns:
        both mean of the predictions and the std

    - #### getUpdatedWeights

          protected abstract double[][] getUpdatedWeights()

      implements the model specific gradient updates.
      Returns:
        var means and stds

    - #### evaluate

          public abstract double evaluate(double[] features,
                                          Object expected)

    - #### setAddBias

          public void setAddBias(boolean val)

    - #### getNumFeatures

          public int getNumFeatures()

    - #### setNumFeatures

          public void setNumFeatures(int val)

    - #### getNumSamples

          public int getNumSamples()

    - #### setNumSamples

          public void setNumSamples(int val)

    - #### getOptimizerType

          public BayesianModel.OptimizerType getOptimizerType()

    - #### setOptimizerType

          public void setOptimizerType(BayesianModel.OptimizerType val)

    - #### getLearningRate

          public double getLearningRate()

    - #### setLearningRate

          public void setLearningRate(double val)

    - #### setPredictionSamples

          public void setPredictionSamples(int val)

Copyright © 2022 WSO2. All rights reserved.