vastorbit.machine_learning.memmodel.naive_bayes.NaiveBayes.predict_proba_sql¶
- NaiveBayes.predict_proba_sql(X: Annotated[list | ndarray, 'Array Like Structure']) list[str]¶
Returns the SQL code needed to deploy the model probabilities using its attributes.
- Parameters:
X (ArrayLike) – The names or values of the input predictors.
- Returns:
SQL code.
- Return type:
list
Examples
Import the required module.
from vastorbit.machine_learning.memmodel.naive_bayes import NaiveBayes
Let’s define attributes representing each input feature:
attributes = [ { "type": "gaussian", "C": {"mu": 63.9878308300395, "sigma_sq": 7281.87598377196}, "Q": {"mu": 13.0217386792453, "sigma_sq": 211.626862330204}, "S": {"mu": 27.6928120412844, "sigma_sq": 1428.57067393938}, }, { "type": "multinomial", "C": 0.771666666666667, "Q": 0.910714285714286, "S": 0.878216123499142, }, { "type": "bernoulli", "C": 0.771666666666667, "Q": 0.910714285714286, "S": 0.878216123499142, }, { "type": "categorical", "C": { "female": 0.407843137254902, "male": 0.592156862745098, }, "Q": { "female": 0.416666666666667, "male": 0.583333333333333, }, "S": { "female": 0.406666666666667, "male": 0.593333333333333, }, }, ]
We also need to provide class names and their prior probabilities.
prior = [0.8, 0.1, 0.1] classes = ["C", "Q", "S"]
Let’s create a model.
model_nb = NaiveBayes(attributes, prior, classes)
Let’s use the following column names:
cnames = ["age", "pclass", "survived", "sex"]
Get the SQL code needed to deploy the model.
model_nb.predict_proba_sql(cnames)
Note
Refer to
NaiveBayesfor more information about the different methods and usages.