Bring Your Own Model
The Bring Your Own Model (BYOM) feature lets you upload your own models in the form of Python code and use them within MindsDB.
How It Works
You can upload your custom model via the MindsDB editor by clicking Add
and Upload custom model
, like this:
Here is the form that needs to be filled out in order to bring your model to MindsDB:
Let’s briefly go over the files that need to be uploaded:
-
The Python file stores an implementation of your model. It should contain the class with the implementation for the
train
andpredict
methods. Here is the sample format:
-
The optional requirements file, or
requirements.txt
, stores all dependencies along with their versions. Here is the sample format:
Once you upload the above files, please provide an engine name.
Please note that your custom model is uploaded to MindsDB as an engine. Then you can use this engine to create a model.
Let’s look at an example.
Example
We upload the custom model, as below:
Here we upload the model.py
file that stores an implementation of the model and the requirements.txt
file that stores all the dependencies.
Once the model is uploaded, it becomes an ML engine within MindsDB. Now we use this custom_model_engine
to create a model as follows:
Let’s query for predictions by joining the custom model with the data table.
Check out the BYOM handler folder to see the implementation details.