/ML-algorithms-step-by-step-implementations

Step-by-step implementation of basic machine learning algorithms with performance comparisons against the sklearn implementation and solving classification and prediction problems.

Primary LanguageJupyter Notebook

๐Ÿงฎ ML Algorithms: Step-by-Step Implementations

Step-by-step implementation of basic machine learning algorithms with performance comparisons against the sklearn implementation and solving classification and prediction problems.


1. Linear Regression

  • ๐Ÿ“‰ Implemented both analytical and numerical solutions:
    • Closed-form linear regression
    • Powellโ€™s optimization method (scipy)
  • ๐Ÿงช Tested on synthetic 1D datasets (make_regression, noise=16)
  • โฑ๏ธ Compared in terms of accuracy and runtime

2. Linear Classification

  • ๐Ÿงพ Analytical implementation with Tikhonov regularization
  • ๐Ÿงช Benchmarked against RidgeClassifier from sklearn
  • โค๏ธ Applied to Cleveland Heart Disease dataset:
    • Data preprocessing, outlier removal
    • Statistical profiling and feature selection (manual vs automatic)

3. Logistic Regression

  • โš™๏ธ Custom implementation using:
    • Gradient Descent (with learning rate tuning)
    • โœจ Mini-Batch optimization
    • ๐Ÿ“‰ Squared Gradients Sum (AdaGrad-style)
  • ๐Ÿงช Tested on synthetic datasets:
    • Binary classification
    • Multi-class scenarios

4. SVM (Support Vector Machines)

  • ๐Ÿ”ง Three kernel implementations:
    • โž– Linear Kernel (hard/soft margin)
    • ๐Ÿ”ถ Polynomial Kernel (degree customization)
    • ๐ŸŒ RBF Kernel (gamma parameter tuning)
  • โš–๏ธ Benchmarking against sklearn's SVM:
    • Accuracy comparison
    • Training time analysis
  • ๐Ÿ“Š Visualization of decision boundaries

5. Decision Tree

  • ๐ŸŒก๏ธ Entropy Minimization approach:
    • Recursive binary splitting
    • Pre-pruning parameters
  • ๐Ÿงช Test scenarios:
    • Single-feature datasets
    • High-dimensional multi-class problems
  • ๐Ÿ“‰ Comparison with sklearn's DecisionTreeClassifier

6. Random Forest

  • ๐Ÿ—๏ธ Custom ensemble features:
    • Bagging with replacement
    • Feature subspace selection
    • Comparison with sklearn.ensemble.RandomForest

7. Neural Network

  • ๐Ÿง  Manually built multi-layer feedforward neural network
  • ๐Ÿ“ฆ Trained on MNIST with adjustable activation functions (e.g., ReLU, Sigmoid)
  • ๐Ÿ“ˆ Reports metrics after each epoch: accuracy, sensitivity, specificity

๐Ÿ‘จโ€๐Ÿ’ป Author

Paweล‚ Marchel
If you find this project helpful, feel free to star โญ the repo or get in touch for collaboration.