Sign inGet started
All posts

– by Allan on February 15, 2022

SQL just got machine learning

It's almost a given that the brightest tools in machine learning are written for Python. However, those with the deepest understanding of company data often speak SQL. Imagine what they could do if machine learning was at their fingertips—not in a Python environment but in the data layer—where they're most effective.

The coalescence of machine learning tools into the Python ecosystem makes sense when you consider all steps that are required to train and test models: cleaning, transformation, visualization, and so on. There's so much iteration involved in machine learning that using a data science programming language seems necessary.

However, the marriage of Python and machine learning, while sensible, does have a trade off: Database professionals are more likely to speak SQL than Python. The 2020 Stack Overflow survey bears this out nicely, showing an ML cluster centered around Python, and a separate cluster linking SQL with database technologies.


Based on this, if we assume that data/analytics engineers are "closest" to their company's data, then why not put tools in their hands that unlock the full potential of their domain expertise?

This is where MindsDB comes in. MindsDB moves ML to the data layer, right where data engineers are most effective. Not only do models and predictions live alongside a company's data but the whole ML pipeline is operated using SQL—no Python needed, but more on that in a second…first, look at how easy it is to train a model with MindsDB:

CREATE PREDICTOR customer_satisfaction_model
FROM customers_db
    (SELECT * FROM customers_table LIMIT 1000) 
PREDICT customer_satisfaction;

The query above will train a new model called customer_satisfaction_model based on data in the customers table. The nested SELECT statement indicates that all columns from the customers table are used to predict customer satisfaction.

Now, once the model is trained, it is equally straightforward to make a prediction:

SELECT customer_satisfaction
FROM mindsdb.customer_satisfaction_model 
WHERE age=47 AND type='Business' AND gender='Male';

And that's all there is to returning a prediction from the trained model!

As you can see, MindsDB enables machine learning in just a few lines of code. In order to use MindsDB, you’d need to install it, set a few things up, and write some SQL. But wouldn’t it be nice to just jump into a notebook and play with MindsDB immediately? We got you.

Since Deepnote is a data science platform designed to bring teams, tools, and workflows together, it demonstrates MindsDB perfectly. This is especially true because SQL is a first-class citizen in Deepnote. SQL cells look and function beautifully; interlace Python and SQL, and return Pandas Dataframes from SQL queries. Mega-interoperability.

Jump into Deepnote’s MindsDB template now and start leveraging your SQL knowledge for machine learning.

Share this post

Twitter icon

Allan Campopiano

Solutions Engineer @ Deepnote

Follow Allan on LinkedIn and GitHub

Join the world's best data teams and get started with Deepnote

No credit card required. Run your first notebook in seconds.



  • Integrations
  • Pricing
  • Documentation
  • Changelog
  • Security



  • Privacy
  • Terms

© Deepnote