Welcome to Pynot, a repository dedicated to implementing machine learning algorithms from scratch.
This repository contains implementations of various machine learning algorithms written from scratch in Python. The aim is to provide a clear understanding of how these algorithms work under the hood.
This project is designed for educational purposes to help you understand the inner workings of popular machine learning algorithms. By implementing these algorithms from scratch, you will gain a deeper insight into their mechanics, which is often abstracted away by high-level libraries such as scikit-learn or TensorFlow.
The following algorithms are currently implemented in this repository:
- Linear Regression
- Logistic Regression
- Decision Tree
- Random Forest
- Neural Networks
- Support Vector Machine (SVM) - On Going
- K-Nearest Neighbors (KNN) - On Going
- Principal Component Analysis (PCA) - On Going
Each algorithm is implemented in its own module with a corresponding example script demonstrating its usage.
To get started, clone the repository and install the required dependencies.
git clone https://github.com/omartarekmoh/ML_From_Scratch.git
cd ML_From_Scratch
pip install -r requirements.txt
Each algorithm can be used by importing the respective module. Below is an example of how to use the Linear Regression implementation.
from pyatch.linear_models.LinearRegression import LinearRegression
import numpy as np
# Generate some example data
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.array([1, 2])) + 3
# Initialize and train the model
model = LinearRegression()
model.fit(X, y)
# Make predictions
predictions = model.predict(X)
print(predictions)
You can find comparison scripts for each algorithm in the comparisons
directory. These scripts demonstrate how to use the algorithms on various datasets and it's preformace against the scikit-learn algorithms. To run a comparison
This can be used with any model that was made
- Navigate to the comparisons directory within the project.
- Run the
*model_name*_comparison.py
script.
cd comparisons
python linear_regression_comparison.py
Contributions are welcome! If you would like to add a new algorithm, improve existing implementations, or fix bugs, please open a pull request. Make sure to follow the contribution guidelines.
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a pull request