Memuat
Memuat
Watch every step above performed live, with English narration.
0 plays
Class book
Page 1 / 8
Cover: Machine Learning Python Class #1: Introduction to Machine Learning & First Model
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Machine Learning Python Class #1: Introduction to Machine Learning & First Model”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
This is the final result, our first machine learning model that can predict the type of iris flower just from the size of its petals, and successfully predicted all flowers in the test data correctly, even though it had never seen them before. We also compared it with K-Means, an algorithm that groups data without any labels at all. Let's get started. Hello, welcome to the machine learning tutorial series with Python, episode one. Machine learning is a way to make computers learn from data, not from rules that we write one by one. In regular programming, we give data and rules, then the computer produces the answer. In machine learning, we give data along with the answer, then the computer itself finds the rules. There are three main types, supervised learning which learns from labeled data, unsupervised learning which finds patterns without labels, and reinforcement learning which learns from rewards and punishments. In this video, we try the first two directly.
The first step, we open the terminal in VS Code via the terminal menu, then new terminal. We check the Python version, then make sure the scikit-learn library is installed. If not, just type pip install scikit-learn pandas matplotlib. After that, we create our first file named lihat underscore data dot py. We start by getting to know the data.
The iris dataset is already available inside scikit-learn, so there's no need to download it. This dataset contains 150 flowers from three species, setosa, versicolor, and virginica. Each flower has four measurements, length and width of sepal, as well as length and width of petal. These four measurements are called features, while the species is called the target or label. We convert it into a pandas data frame for better organization, then display the data size, the first five rows, and the count of each species. Before training the model, it's a habit to look at the data.
We create a scatter plot of petal length against petal width, with different colors for each species. Notice the result, the three species form fairly separated groups. Setosa is clearly distinct in the lower left, while versicolor and virginica are close to each other. This is the pattern that the model will later learn.
Now, the core part: training the model. We create a new file, model_underscore_first_dot_paye. The pattern is always the same in scikit-learn. First, split the data into train test split, 80% for training, 20% for testing. The test data should not be seen by the model while learning, so that we know the model's true capability. Second, create a model object, here decision tree classifier. Third, call fit to train. Fourth, call predict to guess the test data, then calculate the accuracy with accuracy score.
The accuracy is 1.0, meaning 100%. All flowers in the test data were predicted correctly, even though the model had never seen them before. Now we try to predict a new flower. We input its four measurements, then the model tells us its species. This is called inference, using a trained model to predict new data.
Finally, we try unsupervised learning. Create a file group dot paye. This time we use k-means and intentionally do not provide any species labels at all. We only ask k-means to divide the flowers into three groups based on similarity of measurements. Then we draw two side-by-side graphs. Left using the original labels, right using the results of k-means. The results are very similar. K-means successfully found the species groups without ever being told the answers.
Done. We have now learned what machine learning is, its types, and the workflow of scikit-learn. Split data, feed, predict, then evaluate. We also compare supervised learning with decision tree and unsupervised learning with k-means. In the next episode, we will dive deeper into the main tools of data scientists, namely Nampai, Pandas, and Medplotlib. Want to master machine learning and data science? Cerdas Inovasi Digital offers Python, machine learning, and AI courses from the basics, prediction model development services, data analysis, and AI application for business or research, as well as selling complete source code of this tutorial. Want to master the entire series, from machine learning introduction to deploying models to the web? All 18 episodes, complete with PDF step-by-step guides, are available to premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want a single class only? Buy single classes with lifetime access. Subscribe now at the premium page cerdasinovasidigital.com Contact us via WhatsApp, or visit cerdasinovasidigital.com Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →