This repository contains a series of beginner-friendly machine learning lab notebooks and datasets, designed to guide you step by step from basic probability and linear algebra concepts to implementing and evaluating real machine learning algorithms.
The labs are written in Jupyter Notebooks (.ipynb) and use popular Python libraries such as numpy, pandas, matplotlib, and scikit-learn. Each lab focuses on a small, concrete set of ideas with code you can read, modify, and extend on your own.
The core of this repo is a sequence of lab notebooks:
-
i210277_TALHA_LAB_02.ipynb- Works with a small medical diagnosis example (patients with Positive/Negative labels).
- Focuses on classification performance metrics such as:
- True Positive (TP), True Negative (TN), False Positive (FP), False Negative (FN)
- How to compute counts of TP/TN/FP/FN from predicted vs. actual labels
- The intuition behind these values for evaluating classifiers
-
i210277_TALHA_LAB_03.ipynbandi210277_TALHA_LAB_03_Bpart.ipynb- Uses a student exam dataset with variables like
Gender,StudyMethod, andExamResult. - Focuses on categorical data analysis:
- Constructing contingency tables (cross-tabulations) between two categorical variables
- Counting and summarizing how categories relate to each other
- Lays groundwork for understanding probabilities and associations in data
- Uses a student exam dataset with variables like
-
i210277_TALHA_04.ipynb- Introduces key linear algebra concepts used in ML:
- Vectors and dot products
- Computing the projection of one vector onto another
- Builds intuition for geometric ideas behind many ML algorithms (e.g., distances, directions, and components).
- Introduces key linear algebra concepts used in ML:
-
i210277_TALHA_LAB_05.ipynb- Uses the dataset
student_performance.csv. - Focuses on data exploration with pandas:
- Reading CSV files with
pandas.read_csv - Inspecting dataframes (head, info, describe)
- Understanding columns and basic descriptive statistics
- Reading CSV files with
- Helps you become comfortable loading and inspecting real-world tabular data.
- Uses the dataset
-
i210277_TALHA_LAB_06.ipynb- Implements a K-Nearest Neighbors (KNN) classifier from scratch:
- Stores training data explicitly
- Implements Euclidean distance between samples
- Finds the
knearest neighbors and uses majority voting for classification
- Excellent for learning how a simple classification algorithm works internally.
- Implements a K-Nearest Neighbors (KNN) classifier from scratch:
-
i210277_TALHA_LAB_07.ipynb- Uses
numpy,pandas,sklearn.datasets.load_wine,StandardScaler,PCA, andKNeighborsClassifier. - Focuses on:
- Data standardization and feature scaling
- Principal Component Analysis (PCA):
- Computing mean and covariance
- Eigenvalues and eigenvectors
- Projecting 2D data to 1D
- Applying KNN classification on transformed data
- Bridges theory (PCA math) and practical use of scikit-learn.
- Uses
-
i210277_TALHA_LAB_08.ipynbandi210277_TALHA_LAB_08(1).ipynb- Works with a classic PlayTennis-style dataset (Outlook, Temperature, Humidity, Wind, PlayTennis).
- Typically used for rule-based classification / decision tree concepts:
- Representing categorical data
- Understanding how attributes relate to the target variable
- You may see manual calculations of measures like entropy or information gain, or step-by-step reasoning about splits (depending on the version).
-
i210277_TALHA_LAB10.ipynb- Uses
mathandmatplotlib. - Focuses on mathematical functions and visualization, likely in the context of ML algorithms:
- Implementing formulas relevant to learning algorithms
- Plotting curves and results with
matplotlib
- Good for building comfort with numerical computing and plotting results.
- Uses
-
i210277_TALHA_LAB12.ipynb- Implements K-Means clustering from scratch:
- Initializing centroids
- Assigning data points to the nearest centroid (using Euclidean distance)
- Updating centroids iteratively until convergence
- Helps you understand unsupervised learning and how clusters are formed.
- Implements K-Means clustering from scratch:
-
i210277_TALHA_LAB13.ipynbandi210277_TALHA_LAB_13.ipynb- Starts with data exploration on a custom dataset (e.g.,
body_length,body_breadth,lifespan_indicator,activity_level). - Focuses on:
- Exploratory Data Analysis (EDA)
- Inspecting and understanding new features
- Potentially building simple models or doing clustering/classification on this data
- Useful as a capstone-style lab to combine EDA and modeling skills.
- Starts with data exploration on a custom dataset (e.g.,
These notebooks are not part of the core tutorial flow but are useful as reference or practice:
i210277_AI_B_MidExam.ipynb– likely a midterm-style exam notebook covering concepts from early labs.i210277_AIA_FinalExam.ipynb– likely a final exam notebook covering later/combined topics.wsd_capsNet.ipynbandwsd_capsNet(1).ipynb– more advanced notebooks (e.g., word sense disambiguation or Capsule Networks) beyond the absolute beginner level.
You can explore these after you feel comfortable with the main labs.
The *.csv files provide small, beginner-friendly datasets:
-
student_performance.csv- Used in
i210277_TALHA_LAB_05.ipynb. - Contains information about students and their performance (e.g., study time, scores, etc.).
- Ideal for practice with data loading, exploration, and simple analysis.
- Used in
-
categorical_dataset.csv- A generic categorical dataset for practicing probability, contingency tables, and possibly decision trees.
- Useful when learning to handle non-numeric variables.
-
Iris.csv- The classic Iris flower dataset: measurements of sepal/petal length/width and species labels.
- Widely used for beginner classification (e.g., KNN, decision trees, SVM).
-
penguins.csv- A dataset similar to the Palmer Penguins dataset, with penguin measurements and species.
- Great for visualization, EDA, and multi-class classification practice.
To get the most out of these labs, you should have:
- Basic Python knowledge
- Variables, lists, dictionaries, functions, loops, and conditionals.
- Some math background
- High-school level algebra
- Basic understanding of vectors and simple probability
- Python: Version 3.8 or later is recommended.
- Jupyter Notebook or JupyterLab (or VS Code with Jupyter extensions).
- Python libraries commonly used in these labs:
numpypandasmatplotlibscikit-learn
You can install these using pip in a virtual environment.
-
Download or copy this folder
- If you received it as a
.zip, extract it (e.g.,d:\Fall2025\ML-R1). - If using git, you could later turn this into a repo, but it is not required.
- If you received it as a
-
Create and activate a virtual environment (recommended):
# from inside d:\Fall2025\ML-R1 python -m venv .venv .venv\Scripts\activate
-
Install the required Python packages:
pip install numpy pandas matplotlib scikit-learn
-
Launch Jupyter Notebook or JupyterLab:
jupyter notebook
or
jupyter lab
-
Open a lab notebook
- In the Jupyter interface, navigate to this folder.
- Click on any
.ipynbfile (for example,i210277_TALHA_LAB_02.ipynb) to start.
If you are a complete beginner, the following order is recommended:
-
Start with basic concepts and math:
i210277_TALHA_LAB_02.ipynb– Understanding TP/TN/FP/FN and classification metrics.i210277_TALHA_LAB_03.ipynb/i210277_TALHA_LAB_03_Bpart.ipynb– Categorical data and contingency tables.i210277_TALHA_04.ipynb– Vector operations and projections (linear algebra foundations).
-
Move to data exploration:
i210277_TALHA_LAB_05.ipynb– Loading CSVs, basic EDA withpandas.- Practice with
student_performance.csv,categorical_dataset.csv, and optionallyIris.csv/penguins.csv.
-
Study classic ML algorithms:
i210277_TALHA_LAB_06.ipynb– KNN classifier implemented from scratch.i210277_TALHA_LAB_07.ipynb– PCA and KNN with scikit-learn on the wine dataset.i210277_TALHA_LAB_08.ipynb– Rule-based reasoning / decision tree concepts with PlayTennis-style data.
-
Dive deeper into unsupervised learning and visualization:
i210277_TALHA_LAB10.ipynb– Numerical computations and plots related to ML concepts.i210277_TALHA_LAB12.ipynb– K-Means clustering from scratch.i210277_TALHA_LAB13.ipynb– EDA and modeling on a custom dataset.
-
Optional / Advanced:
i210277_AI_B_MidExam.ipynbandi210277_AIA_FinalExam.ipynb– Use as practice exams.wsd_capsNet.ipynb– Explore only after you are very comfortable; this is not beginner-level.
-
Read the markdown cells first
- Many notebooks start with explanations or “Task” descriptions.
- Understand the goal before running or editing code.
-
Run cells one by one
- Use
Shift + Enterto run each cell. - Watch outputs carefully (printed results, tables, plots).
- Use
-
Experiment with changes
- Change input data (e.g., feature values, labels) and re-run to see effects.
- Modify parameters like
kin KNN or the number of clusters in K-Means.
-
Write small notes (comments) for yourself
- Add short comments explaining in your own words what each block of code does.
- This deepens your understanding and helps when revisiting later.
-
Module not found (e.g.,
ModuleNotFoundError: No module named 'pandas')- Make sure you activated your virtual environment and installed packages:
.venv\Scripts\activate pip install numpy pandas matplotlib scikit-learn
- Make sure you activated your virtual environment and installed packages:
-
Notebook uses a different kernel
- In Jupyter, ensure the kernel is the Python environment where you installed the packages (
Kernel→Change kernel).
- In Jupyter, ensure the kernel is the Python environment where you installed the packages (
-
Plots not appearing
- Make sure you have run all previous cells, especially any imports like
import matplotlib.pyplot as plt.
- Make sure you have run all previous cells, especially any imports like
-
Data file not found (e.g.,
FileNotFoundError: student_performance.csv)- Check that:
- You are running the notebook from the correct folder (
d:\Fall2025\ML-R1). - The CSV file name and path in the code match the actual file name.
- You are running the notebook from the correct folder (
- Check that:
Once you are comfortable with all the labs in this repository, you can:
- Try more complex datasets (Kaggle, UCI ML Repository, etc.).
- Implement other algorithms from scratch (e.g., logistic regression, decision trees, Naive Bayes).
- Practice building end-to-end projects:
- Problem definition
- Data collection and cleaning
- EDA, feature engineering
- Model training, evaluation, and deployment (even if only locally).
This repository is a solid foundation for your journey into machine learning. Take your time with each notebook, experiment freely, and don’t hesitate to revisit earlier labs as your understanding grows.