Home Artificial Intelligence Find out how to Train a Decision Tree Classifier… In SQL Dataset Loading and Preprocessing

Find out how to Train a Decision Tree Classifier… In SQL Dataset Loading and Preprocessing

0
Find out how to Train a Decision Tree Classifier… In SQL
Dataset Loading and Preprocessing

SQL can now replace Python for many supervised ML tasks. Must you make the switch?

Towards Data Science
Photo by Resource Database on Unsplash

Relating to machine learning, I’m an avid fan of attacking data where it lives. 90%+ of the time, that’s going to be a relational database, assuming we’re talking about supervised machine learning.

Python is amazing, but pulling dozens of GB of knowledge at any time when you desire to train a model is a big bottleneck, especially if you might want to retrain them incessantly. Eliminating data movement makes quite a lot of sense. SQL is your friend.

For this text, I’ll use an always-free Oracle Database 21c provisioned on Oracle Cloud. I’m undecided for those who can translate the logic to other database vendors. Oracle works like a charm, and the database you provision won’t cost you a dime — ever.

I’ll leave the Python vs. Oracle for machine learning on huge dataset comparison for another time. Today, it’s all about getting back to basics.

I’ll use the next dataset today:

So download it to follow along, and be certain that you’ve a connection established to your database instance. Tools like SQL Developer or Visual Studio Code can try this for you.

Find out how to Create a Database Table

The next code snippet will create the iris table. The id column is mandatory, as Oracle will need it behind the scenes:

create sequence seq_iris;

create table iris(
id number default seq_iris.nextval,
sepal_length number(2, 1),
sepal_width number(2, 1),
petal_length number(2, 1),
petal_width number(2, 1),
species varchar2(15)
);

Once the table is created, it’s time to load the info.

Find out how to Load CSV Data Into the Table

LEAVE A REPLY

Please enter your comment!
Please enter your name here