A library that returns ML algorithm source code implemented from scratch
Project description
MyMLScratch
A Python library that returns the complete source code for various machine learning algorithms implemented from scratch using pure Python and NumPy.
Installation
pip install mymlscratch
Usage
import mymlscratch
# Get Linear Regression code
code = mymlscratch.get_linear_regression_code()
print(code)
# Save to a file
with open('linear_regression.py', 'w') as f:
f.write(code)
# Execute the code
exec(code)
# List all available algorithms
algorithms = mymlscratch.list_available_algorithms()
print(algorithms)
Available Algorithms
- Linear Regression -
get_linear_regression_code() - Logistic Regression -
get_logistic_regression_code() - K-Nearest Neighbors -
get_knn_code() - Decision Tree -
get_decision_tree_code()(coming soon) - K-Means Clustering -
get_kmeans_code()(coming soon)
Features
- ✅ Pure Python/NumPy implementations
- ✅ Complete, runnable source code
- ✅ Educational comments and docstrings
- ✅ Example usage included in each algorithm
- ✅ No dependencies except NumPy
Use Cases
- Learning: Study how ML algorithms work under the hood
- Teaching: Use in educational materials and courses
- Customization: Get base code to modify for specific needs
- Prototyping: Quick algorithm implementations for experiments
Example
import mymlscratch
import numpy as np
# Get the code
code = mymlscratch.get_linear_regression_code()
# Execute it
exec(code)
# Now you can use the LinearRegression class
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([2, 4, 6, 8, 10])
model = LinearRegression(learning_rate=0.01, n_iterations=1000)
model.fit(X, y)
predictions = model.predict(X)
print("Predictions:", predictions)
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mymlscratch-0.1.0.tar.gz.
File metadata
- Download URL: mymlscratch-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bdcc1f8ecc44e7288c6a8511e6eab8c87337083bfb503ca222af7cbad96f600
|
|
| MD5 |
0450bb02fb9df2dd8bca7bf65e9ef324
|
|
| BLAKE2b-256 |
be4c91317b2850bcfe9a0fc17e9c9261c4d10a55902d41b3b629895f98dec6e5
|
File details
Details for the file mymlscratch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mymlscratch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f82e74a5eb54c961e10f79524f91aa623535cea9cdedb28d86711feb211d905
|
|
| MD5 |
12194ef722a06e4281e37d9fd3996bf7
|
|
| BLAKE2b-256 |
bbd63e71a05e93bf61e5da6739c9cdb02dbaea2631fe7a3b0640f3fa9136d451
|