Skip to content

TeenBiscuits/Practicas-ML

Repository files navigation

Machine Learning Assignments

Assignments for the Introduction to Machine Learning course (26VT-2DV516) at Linnaeus University (LNU).

Learning Assignment 1 Assignment 2 Assignment 3 Exam Drills
Open in molab Open in molab Open in molab Open in molab Deploy to GitHub Pages
Open in GitHub Open in GitHub Open in GitHub Open in GitHub Website
just for fun idk Grade: A Grade: A Grade: B /web-exam

Project Structure

.
├── learning.ipynb / learning.py   # Introductory Python, NumPy, Matplotlib, and scikit-learn notebook
├── __marimo__/                    # Marimo session state
├── pyproject.toml                 # Project metadata, dependencies, and Poe tasks
├── uv.lock                        # Locked dependency versions
├── .python-version                # Python 3.14
│
├── assignments/
│   ├── assignment-1/
│   │   ├── A1.ipynb / A1.py       # k-Nearest Neighbors
│   │   ├── __marimo__/            # Marimo session state
│   │   ├── MachineLearningModel.py
│   │   ├── IrisDataset.csv
│   │   ├── Polynomial200.csv
│   │   └── mnist/                 # MNIST handwritten digits dataset
│   │
│   ├── assignment-2/
│   │   ├── pp222rp_A2.ipynb / pp222rp_A2.py
│   │   ├── __marimo__/            # Marimo session state
│   │   ├── MachineLearningModel.py
│   │   ├── DecisionBoundary.py
│   │   ├── ForwardSelection.py
│   │   ├── ROCAnalysis.py
│   │   └── datasets/              # Banknote, heart disease, Boston housing, secret polynomial
│   │
│   └── assignment-3/
│       ├── pp222rp_A3.ipynb / pp222rp_A3.py
│       ├── __marimo__/            # Marimo session state
│       ├── bkmeans.py             # Bisecting k-Means implementation
│       ├── datasets/
│       │   ├── BankMarketing/     # Bank Marketing dataset
│       │   └── your_datasets/     # Adult, default, and dropout datasets
│   └── *.png                  # Generated plots used by the assignment
│
├── web-exam/                      # React SPA — exam drill questions with simulations & self-grading
│
├── datasets/                      # Shared datasets (admission, Boston housing, iris, microchips, secret polynomial)
└── docs/
    ├── __marimo__/                # Marimo session state
    └── pyplot.ipynb / pyplot.py   # Matplotlib notes/tutorial

Assignments

Assignment 1: k-Nearest Neighbors

Implementation of k-NN regression and classification from scratch with NumPy, Matplotlib, and SciPy.

  • KNN regression and classification: custom models using Euclidean distance, tested on Polynomial200 and Iris with decision-boundary contour plots across varying k.
  • Regression validation: repeated random-split experiments with MSE bar charts across multiple k values.
  • Feature combination search: exhaustive search over 2-feature combinations on Iris to find the best classification performance.
  • Fast KNN with KDTree: SciPy KDTree-based model benchmarked for performance against the naive implementation.
  • MNIST classification: handwritten-digit classification on MNIST using the fast KNN model.

Assignment 2: Regression, Classification, and Neural Networks

Implementation of regression and classification models from scratch, followed by scikit-learn experiments.

  • Normal equation and gradient descent regression: closed-form and iterative polynomial regression on Boston Housing, with normalization, cost-evolution plots, and hyperparameter tuning.
  • Polynomial degree selection: model-fit comparison across polynomial degrees with shuffled-run validation.
  • Logistic and non-linear logistic regression: binary classification on banknote authentication, hyperparameter analysis, and decision boundary visualizations.
  • ROC analysis and forward selection: custom ROC metrics and feature selection on the heart disease Cleveland dataset.
  • Neural networks: MLPClassifier with GridSearchCV on the digits dataset, including confusion matrix and loss analysis.

Assignment 3: Trees, Ensembles, SVM, PCA, and Clustering

Use of scikit-learn and custom algorithms for advanced machine-learning tasks.

  • Decision trees and ensembles: Bank Marketing dataset preprocessing, tree visualization, depth/overfitting analysis, and comparison of Random Forest and Gradient Boosting with ROC/AUC and feature importance plots.
  • Robustness to noise: synthetic noise injected into the dataset to test ensemble model resilience.
  • SVM: Breast Cancer dataset with PCA, linear vs RBF kernel comparison, grid search over C and gamma, and logistic regression benchmark.
  • Bisecting k-Means: custom implementation from scratch, tested on synthetic blobs and 3 real-world datasets with PCA projections.
  • Dimensionality reduction and clustering comparison: PCA, MDS, and t-SNE side by side, plus comparison of bisecting k-Means, classic k-Means, and hierarchical clustering on t-SNE projections.

Installation

This project requires Python 3.14 and uv.

git clone https://github.com/TeenBiscuits/Practicas-ML.git
cd Practicas-ML
uv sync

Running Notebooks

Run commands from the repository root so the relative dataset paths used by the notebooks resolve correctly.

# Open the Marimo editor
uv run poe marimo

# Open Jupyter Lab
uv run poe lab

You can also open the notebooks directly from GitHub or Molab using the badges above.

Technologies

  • Python 3.14
  • uv for dependency management
  • Marimo and Jupyter Lab for notebooks
  • NumPy for array operations and linear algebra
  • Matplotlib for visualizations
  • scikit-learn for models, metrics, preprocessing, dimensionality reduction, and clustering
  • SciPy for KDTree-based nearest-neighbor search
  • React + TypeScript + Tailwind CSS + Vite for the exam practice web app

About

Assignments for the Introduction to Machine Learning course at LNU (26VT-2DV516)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors