R
Rishtaara
Python: Zero to Professional
Lesson 29 of 40Article18 min

Machine Learning — Getting Started & Data

Machine Learning (ML) teaches computers to learn patterns from data instead of hard-coded rules.

Machine Learning — Getting Started

Machine Learning (ML) teaches computers to learn patterns from data instead of hard-coded rules.

Python is the top ML language thanks to NumPy, Pandas, scikit-learn, and Matplotlib.

Real-life example: ML is a student who improves by practicing past exam papers — not memorizing one answer key.

Data Set

A data set is any collection — a Python list, CSV file, or database table.

ML starts by exploring raw data before building models.

Real-life example: A data set is a cricket scorebook — rows are matches, columns are runs, wickets, overs.

Simple data set
scores = [88, 92, 75, 81, 95]
print(len(scores), max(scores), min(scores))

Data Types — Numerical, Categorical, Ordinal

Numerical: discrete (counts) or continuous (measurements). Categorical: labels like colors. Ordinal: ordered categories like grades.

Knowing types tells you which algorithms and preprocessing steps fit.

Real-life example: Shoe size (numerical) vs brand (categorical) vs rating stars (ordinal) — different questions need different tools.

Viewing Data with Python

Pandas read_csv() and head() preview tables. Look before you model.

Spot missing values, wrong types, and outliers early.

Real-life example: Viewing data is opening the hood before driving — see if anything is leaking.

Preview with Pandas
import pandas as pd

data = {"name": ["A", "B", "C"], "score": [88, 92, 75]}
df = pd.DataFrame(data)
print(df.head())
print(df.info())

Data Dimensions

df.shape returns (rows, columns). Large row counts mean more training examples.

Too many columns without enough rows can cause overfitting.

Real-life example: Dimensions are classroom size — 30 students × 5 subjects is a clear grid to reason about.

Shape property
import pandas as pd

df = pd.DataFrame({"a": [1, 2], "b": [3, 4], "c": [5, 6]})
print(df.shape)  # (2, 3)