Sign inGet started
← Back to all posts

SQL just got machine learning

By Allan Campopiano

Updated on February 15, 2022

The people with the deepest understanding of company data typically speak SQL. See how MindsDB puts machine learning at their fingertips.

Illustrative image for blog post

The coalescence of machine learning tools into the Python ecosystem makes sense when you consider all the 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.

mindsdb-chart.png

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 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.

Allan Campopiano

Solutions Engineer @ Deepnote

Follow Allan on LinkedIn and GitHub

Blog

Illustrative image for blog post

How to effectively prompt Deepnote AI

By Ondřej Romancov

Updated on March 26, 2024

That’s it, time to try Deepnote

Get started – it’s free
Book a demo

Footer

Product

  • Integrations
  • Pricing
  • Documentation
  • Changelog
  • Security

Company

Comparisons

Resources

  • Privacy
  • Terms

© Deepnote