A simple machine learning library for educational purposes.
Project description
Tazids Library Documentation
Overview
Tazids is a simple yet powerful machine learning library that provides implementations for various algorithms, including Linear Regression, Decision Trees, and K-Means clustering. The library is designed to help you easily build, train, and apply machine learning models for a variety of tasks, with a focus on transparency and simplicity.
Installation
To install the Tazids library, you can use the following command:
pip install tazids
Directory Structure
The Tazids library is organized as follows:
Tazi_Ds/
├── tazids/
│ ├── __init__.py # Initialization file for the tazids module
│ ├── regressor.py # Contains the LinearRegression class
│ ├── tree.py # Contains the DecisionTree class
│ ├── clustering.py # Contains the KMeans class
└── setup.py # Setup script for installation
Features
Linear Regression Class (LinearRegression)
The LinearRegression class implements a simple linear regression model using gradient descent. It allows you to:
- Train the model on data using gradient descent.
- Predict outcomes for new data.
- Monitor the training process with loss values.
Example Usage
import numpy as np
from tazids.regressor import LinearRegression
# Generate synthetic data
X = np.random.rand(100, 1) * 10
y = 5 * X + np.random.randn(100, 1) * 2 # Linear relationship with noise
# Initialize and train the model
model = LinearRegression()
model.fit(X, y, learning_rate=0.01, iters=1000)
# Make predictions
predictions = model.predict(X)
Decision Tree Class (DecisionTree)
The DecisionTree class implements a simple decision tree for classification tasks. It supports:
- Recursive splitting of the data to build the decision tree.
- Making predictions by traversing the tree for each input sample.
Example Usage
from tazids.tree import DecisionTree
from sklearn.datasets import load_iris
# Load dataset
data = load_iris()
X, y = data.data, data.target
# Initialize and train the model
model = DecisionTree()
model.fit(X, y)
# Make predictions
predictions = model.predict(X)
KMeans Class (KMeans)
The KMeans class implements the K-Means clustering algorithm for unsupervised learning. It clusters data points into k groups by:
- Initializing random centroids.
- Assigning points to the nearest centroid.
- Updating centroids iteratively until convergence.
Example Usage
from tazids.clustering import KMeans
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
# Generate synthetic data
X, _ = make_blobs(n_samples=300, centers=4, cluster_std=0.6, random_state=42)
# Initialize and train the KMeans model
model = KMeans(n_iter=300, tol=1e-4)
model.fit(X, k=4)
# Predict cluster labels
predictions = model.predict(X)
# Visualize the results
plt.scatter(X[:, 0], X[:, 1], c=predictions, cmap='viridis', s=30)
plt.scatter(model.centroids[:, 0], model.centroids[:, 1], c='red', marker='x', s=200, label='Centroids')
plt.legend()
plt.title("KMeans Clustering")
plt.show()
Notes
- Tazids is designed to be simple and transparent for educational and research purposes.
- Transparency: All models are built from scratch to provide a better understanding of their inner workings.
- Learning-Oriented: Ideal for students and researchers who want to explore the basics of machine learning.
- Lightweight: Minimal dependencies to keep the library easy to use.
- For advanced use cases, consider established libraries like scikit-learn, but Tazids offers a perfect entry point to learn the fundamentals.
Made By Mohannad Tazi
Project details
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 tazids-1.2.0.tar.gz.
File metadata
- Download URL: tazids-1.2.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22049bdf67afa8b7507a508694c49237d3ac8f5903e19a777e7b9a645c372860
|
|
| MD5 |
6c91ac0156f33b3c0ad34816ca314dcf
|
|
| BLAKE2b-256 |
50160b800fa12c526e8a814c1719f5df8c155f3c68c1349b4adcc990063d66f2
|
File details
Details for the file tazids-1.2.0-py3-none-any.whl.
File metadata
- Download URL: tazids-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9db245c2dceeb420844d7320387cbadef55b151cf2cffdc0360ad3b74034b44
|
|
| MD5 |
1cab1b76cc6180cb9cd3c47b8df8c95b
|
|
| BLAKE2b-256 |
6e4f164fa87470fa28a9e3ece88efeeaec2078bafa8e5fc002cb32289a7f78a0
|