Description

The db.models.deleteOne() method deletes an ML model specified in its argument.

Syntax

Here is the syntax:

db.models.deleteOne({name: "predictor_name"});

On execution, we get:

{
  "acknowledged": true,
  "deletedCount": 1
}

Where:

NameDescription
nameName of the model to be deleted.

Example

Before deleting a predictor, let’s list all the available predictors using the db.models.find() method.

db.models.find({});

On execution, we get:

{
    "name": "home_rentals_model",
    "status": "complete",
    "accuracy": "1.0",
    "predict": "rental_price",
    "update_status": "up_to_date",
    "mindsdb_version": "22.8.3.1",
    "error": null,
    "select_data_query": "",
    "training_options": ""
},
{
    "name": "other_model",
    "status": "complete",
    "accuracy": "1.0",
    "predict": "value_to_be_predicted",
    "update_status": "up_to_date",
    "mindsdb_version": "22.8.3.1",
    "error": null,
    "select_data_query": "",
    "training_options": ""
}

The db.models.deleteOne() method drops the model collection called home_rentals_model.

db.models.deleteOne({name: "home_rentals_model"});

On execution, we get:

{
  "acknowledged": true,
  "deletedCount": 1
}

You can validate that the model was removed by listing all the predictors.

db.models.find({});

On execution, we get:

{
  "name": "other_model",
  "status": "complete",
  "accuracy": "1.0",
  "predict": "value_to_be_predicted",
  "update_status": "up_to_date",
  "mindsdb_version": "22.8.3.1",
  "error": null,
  "select_data_query": "",
  "training_options": ""
}