Machine Learning Tutorial menu

Machine Learning Tutorial

Machine learning (ML) is a way of building programs that learn patterns from examples, instead of following rules that a programmer writes by hand.

It is the technology behind spam filters, product recommendations, fraud alerts on bank cards, and the price estimates on property websites. Large AI models like ChatGPT, Gemini and Claude are also built on machine learning, at a much bigger scale.

This tutorial teaches the core ideas with short, runnable Python examples using scikit-learn, the most popular library for classic machine learning.

Your First Machine Learning Program

Here a model learns the link between flat size and monthly rent from five examples, then predicts the rent of a new flat:

Example

python
from sklearn.linear_model import LinearRegression

# Size of a flat (square feet) and monthly rent (Rs)
sizes = [[500], [700], [900], [1100], [1300]]
rents = [25000, 32000, 40000, 47000, 55000]

model = LinearRegression()
model.fit(sizes, rents)

print(round(model.predict([[1000]])[0]))
Output
43550

Nobody told the program the formula for rent. It found the pattern from the data. That is machine learning.

What You Will Learn

  • What machine learning is, and the main types of learning
  • How to prepare data and choose features
  • Why we split data into training and test sets
  • Linear regression for predicting numbers
  • Classification and decision trees for predicting categories
  • How to measure a model, and how to spot and fix overfitting

Before You Start

You should know basic Python. Knowing a little NumPy and Pandas helps. Install the libraries with pip install scikit-learn pandas, or use a free online notebook such as Google Colab, where they are already installed.

Exercise

What makes a program "machine learning"?

What to Learn After This

Go further with Data Science for analysing real datasets, the AI tutorial for the bigger picture, and Generative AI to see how today's chat and image models work.

Want to learn with a teacher? The Workownix AI course covers Python, machine learning and modern AI tools with real projects, online or at our institute in Orangi Town, Karachi.

Learn Machine Learning with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp