Mongo-QL
Create, Train, and Deploy a Model
Description
The db.predictors.insertOne()
method creates and trains a new model.
Syntax
Here is the syntax:
db.predictors.insertOne({
name: "predictor_name",
predict: "target_column",
connection: "integration_name",
select_data_query: "db.collection_name.find({})"
});
On execution, we get:
WriteResult({
"nInserted" : 1
})
Where:
Expressions | Description |
---|---|
name | The name of the model to be created. |
predict | The name of the target column to be predicted. |
connection | The name of the integration created via the db.databases.insertOne() method or file upload. |
select_data_query | Object that stores the data collection name to be used for training and validation and additional arguments for filtering the data. |
Checking Predictor Status
After running the db.predictors.insertOne()
method, execute the db.predictors.find()
method from the mindsdb.models
collection to check the status of the model.
db.predictors.find({name: "model_name"});
Example
This example shows how you can create and train the home_rentals_model
machine
learning model to predict the rental prices for real estate properties inside
the dataset.
db.predictors.insertOne({
name: "home_rentals_model",
predict: "rental_price",
connection: "mongo_integration",
select_data_query: "db.home_rentals.find({})"
});
On execution, we get:
WriteResult({
"nInserted" : 1
})
To check the predictor status, query the mindsdb.models
table using the db.predictors.find()
command.
db.predictors.find({name: "home_rentals_model"});
On execution, we get:
{
"name": "home_rentals_model",
"status": "complete",
"accuracy": 0.91,
"predict": "rental_price",
"update_status": "up_to_date",
"mindsdb_version": "22.8.3.1",
"error": null,
"select_data_query": "",
"training_options": ""
}