Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Machine Learning Python #2: Preparing Python, NumPy & Pandas for ML”.
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, we processed employee data with pandas, calculated the average salary per division, and then displayed it as four graphs at once with Matplotlib. These three libraries, Nampai, Pandas, and Matplotlib, are essential tools before entering machine learning. Let's start. Hello, welcome back to the Machine Learning with Python series, episode two. Before training a model, we must be proficient in data processing. In this episode, we install the required libraries, learn Nampai for fast numerical computation, Pandas for processing table data like Excel, and Matplotlib for creating graphs. All examples are directly typed and run in VS Code.
First step, open the terminal via the terminal menu, new terminal, and install all libraries with one command, PIP install Nampai Pandas Matplotlib scikit-learn. Since these are already installed on this computer, PIP only informs that the requirements are already met. We check the version with the command python-c, then create a file Nampai underscore dasar dot py. Nampai provides arrays, which are a collection of numbers much faster than Python lists.
We create one-dimensional and two-dimensional arrays. The shape attribute tells us the size, for example, two rows and three columns. What's special is that operations on arrays apply to every element without the need for loops. X plus Y adds corresponding elements, X times 10 scales everything, and dot calculates the dot product, an operation that will be used in every linear model.
Next, indexing and statistics. We create a matrix of values for three students and three subjects. With a boolean mask, values above 80 can be extracted with just one line. The min function can be calculated per column with the same action as zero, or per row with the same action as one. Argmax gives the index of the student with the highest average. We also create random numbers with SID, so the results are always the same every time it is run.
Now pandas. Create a file pandas underscore dasar dot py. We create a data frame containing data for six employees. Name, city, age, salary, and division. There's one missing age, intentionally, like data in the real world. We save it to a CSV file then read it again with read CSV, the most common format used in machine learning. Then we look at the first five rows, summary statistics with describe, and the number of missing data.
Pandas is very powerful for filtering and summarizing data. We take employees with a salary above 8 million, then IT division employees living in Jakarta with two conditions at once. We fill the missing age with the median, and we add a new column for annual salary. Finally, group by, similar to pivot table in Excel, to calculate the average salary per division.
Finally, visualization. Create a file graphic dot py. With PLT subplots we make four graphs in one window. Line graphs for sine and cosine functions, scatter plot for random points, histogram for height forming a bell curve, and bar chart for average salary per division from the CSV data above. The function tick layout tidies up the spacing between graphs.
Done. We have installed the libraries, used arrays and vector operations with numpy, processed tables with pandas, and created various graphs with matplotlib. In the next episode, we learn the mathematics behind machine learning, and train a regression model from scratch with gradient descent without any machine learning library at all. Want to master machine learning and data science? Cerdas Inovasi Digital offers Python, machine learning, and AI courses from scratch, prediction model development services, data analysis, and AI applications for business or research, as well as selling complete source code of this tutorial. Want to master the entire series, from introduction to machine learning up to deploying the model to the web? All 18 episodes, complete with PDF step-by-step guides, are available for premium tutorial subscribers. Subscribe starting from 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 a single class 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 →