Skip to content

KAMILELH/ML-Algorithms-From-Scratch-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Machine Learning from Scratch (Java)

A custom implementation of core Machine Learning algorithms built entirely in Java without external ML libraries.

๐ŸŽฏ Goal

To deconstruct the "black box" of libraries like Scikit-learn and understand the mathematical foundations of algorithms by engineering them from the ground up.

โšก Algorithms Implemented

  • Linear Regression: Using Gradient Descent optimization.
  • K-Nearest Neighbors (KNN): Custom distance metric calculations.
  • Logistic Regression: Sigmoid activation and cost function minimization.
  • (Add whatever else we worked on: Decision Trees, K-Means, etc.)

๐Ÿ› ๏ธ Tech Stack

  • Language: Java (OOP principles)
  • Math: Linear Algebra & Calculus logic implemented raw.
  • Tools: Maven/Gradle (if you used them), JUnit for testing.

๐Ÿง  What I Learned

Building this from scratch taught me the "magic" behind libraries like Scikit-Learn:

  • Math to Code: How to translate mathematical formulas (like Gradient Descent and Euclidean Distance) into efficient Java code.
  • OOP Design: structuring a clean architecture where different models (KNN, Linear Regression) share a common interface.
  • Data Handling: Writing manual logic to normalize and split data without relying on Pandas.

๐Ÿš€ Future Improvements

Ways I plan to make this engine better:

  • Add More Algorithms: Implement Logistic Regression and a simple Neural Network.
  • CSV Support: Build a parser to read real datasets from .csv files automatically.
  • Optimization: Improve matrix multiplication performance for larger datasets.

๐Ÿ’ป How to Run

This project is built with standard Java (no external ML dependencies).

Option 1: Using Eclipse (Recommended)

  1. Clone this repo: git clone https://github.com/YOUR-USERNAME/YOUR-REPO.git
  2. Open Eclipse and go to File > Open Projects from File System.
  3. Select the project folder.
  4. Navigate to src/ml/app/Main.java.
  5. Right-click and select Run As > Java Application.

Option 2: Terminal

cd src
javac ml/app/Main.java
java ml.app.Main

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages