vastorbit.machine_learning.memmodel.naive_bayes.NaiveBayes.predict_sql¶
- NaiveBayes.predict_sql(X: Annotated[list | ndarray, 'Array Like Structure']) str¶
Returns the SQL code needed to deploy the model.
- Parameters:
X (ArrayLike) – The names or values of the input predictors.
- Returns:
SQL code.
- Return type:
str
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_sql(cnames)
Important
For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.