vastorbit.machine_learning.memmodel.linear_model.LinearModelClassifier¶
- class vastorbit.machine_learning.memmodel.linear_model.LinearModelClassifier(coef: Annotated[list | ndarray, 'Array Like Structure'], intercept: float = 0.0)¶
InMemoryModelImplementation of linear algorithms for classification.- Parameters:
coefficients (ArrayLike) – ArrayLike of the model’s coefficients.
intercept (float, optional) – The intercept or constant value.
- Variables:
input (Attributes are identical to the)
underscore (parameters, followed by an)
('_').
Examples
Initalization
Import the required module.
from vastorbit.machine_learning.memmodel.linear_model import LinearModelClassifier
A linear classifier model is defined by its coefficients and an intercept value. In this example, we will use the following:
coefficients = [0.5, 1.2] intercept = 2.0
Let’s create a
LinearModelClassifier.model_lmc = LinearModelClassifier(coefficients, intercept)
Create a dataset.
data = [[1.0, 0.3], [-0.5, -0.8]]
Making In-Memory Predictions
Use
predict()method to do predictions.model_lmc.predict(data)
Use
predict_proba()method to calculate the predicted probabilities for each class.model_lmc.predict_proba(data)
Deploy SQL Code
Let’s use the following column names:
cnames = ['col1', 'col2']
Use
predict_sql()method to get the SQL code needed to deploy the model using its attributes.model_lmc.predict_sql(cnames)
Use
predict_proba_sql()method to get the SQL code needed to deploy the model that computes predicted probabilities.model_lmc.predict_proba_sql(cnames)
Hint
This object can be pickled and used in any in-memory environment, just like scikit-learn models.
- __init__(coef: Annotated[list | ndarray, 'Array Like Structure'], intercept: float = 0.0) None¶
Methods
__init__(coef[, intercept])Returns the model attributes.
predict(X)Predicts using the input matrix.
Computes the model's probabilites using the input matrix.
Returns the SQL code needed to deploy the model probabilities using its attributes.
predict_sql(X)Returns the SQL code needed to deploy the model using its attributes.
set_attributes(**kwargs)Sets the model attributes.
Attributes
Must be overridden in child class