1. Mongo Commands
  2. Deleting a Predictor

The db.predictors.deleteOne() Method

Description

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

Syntax

Here is the syntax:

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

On execution, we get:

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

Where:

NameDescription
nameName of the model to be deleted.

Example

Listing All the Predictors

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

db.predictors.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": ""
}

Dropping a Predictor

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

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

On execution, we get:

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

Validating the Deletion

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

db.predictors.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": ""
}