Query the model from Microsoft SQL Server
This section assumes that you have trained a new model using SQL client or MindsDB Studio.
Prerequisite
Don't forget to install the prerequisites as explained in connect your data section.
To query the model, you will need to SELECT
from the model table:
exec('SELECT <target_variable> AS predicted,
<target_variable_confidence> AS confidence,
<target_variable_explain> AS info
FROM mindsdb.<model_name>
WHERE <feature value>') AT mindsdb;
Query the model from other databases
Note that even if you have trained the model from the Microsoft SQL Server, you will be able to query it from other databases too.
Query example
The following example shows you how to query the model from a mssql client. The table used for training the model is the Medical insurance dataset. MindsDB will predict the charges
based on the values added in when_data
.
exec('SELECT charges AS predicted,
charges_confidence AS confidence,
charges_explain AS info
FROM mindsdb.insurance_model
WHERE age=30') AT mindsdb;
predicted | confidence | info |
---|---|---|
7571.147 | 0.9 | Check JSON below |
info: {
"predicted_value": 7571.147932782108,
"confidence": 0.9,
"prediction_quality": "very confident",
"important_missing_information": ["smoker", "bmi"]