io.siddhi.extension.execution.streamingml.classification.perceptron.util

## Class PerceptronModel

- java.lang.Object
- - io.siddhi.extension.execution.streamingml.classification.perceptron.util.PerceptronModel

- All Implemented Interfaces:
    Serializable

      public class PerceptronModel
      extends Object
      implements Serializable

  Represents a linear Perceptron Model
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PerceptronModel()`
    `PerceptronModel(PerceptronModel model)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object[]` | `classify(double[] features)` Classify the feature set into class
    `int` | `getFeatureSize()` Get model's feature set size
    `void` | `initWeights(int size)` Initialize model's weights
    `void` | `setBias(double bias)` Set a bias for the model
    `void` | `setLearningRate(double learningRate)` Set a learning rate to the model
    `void` | `setThreshold(double threshold)` Set a threshold to the model
    `double[]` | `update(Boolean label, double[] features)` Mehod to update weight of perceptron model

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

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

- - ### Constructor Detail

    - #### PerceptronModel

          public PerceptronModel()

    - #### PerceptronModel

          public PerceptronModel(PerceptronModel model)

  - ### Method Detail

    - #### update

          public double[] update(Boolean label,
                                 double[] features)

      Mehod to update weight of perceptron model
      Parameters:
        `label` - target class/label value
        `features` - array of feature attributes to train
      Returns:
        array of updated weights

    - #### classify

          public Object[] classify(double[] features)

      Classify the feature set into class
      Parameters:
        `features` - set of feature attributed
      Returns:
        prediction and its probability

    - #### initWeights

          public void initWeights(int size)

      Initialize model's weights
      Parameters:
        `size` - size of the weights array

    - #### getFeatureSize

          public int getFeatureSize()

      Get model's feature set size
      Returns:
        Size of the feature vector

    - #### setBias

          public void setBias(double bias)

      Set a bias for the model
      Parameters:
        `bias` - bias to shift the decision boundary

    - #### setThreshold

          public void setThreshold(double threshold)

      Set a threshold to the model
      Parameters:
        `threshold` - boundary for the prediction

    - #### setLearningRate

          public void setLearningRate(double learningRate)

      Set a learning rate to the model
      Parameters:
        `learningRate` - To avoid the local optima

Copyright © 2025 WSO2. All rights reserved.