A lightweight, intelligent machine learning library built on pure NumPy
Where transparency meets power, and learning meets doing
๐ฆ Install โข ๐ Quick Start โข โจ Features โข ๐ค Contribute
Machine learning shouldn't feel like magic. It should be transparent, intuitive, and intelligent.
NumEdge was born from a simple belief: great ML tools should teach you while you build. Every algorithm is implemented in pure NumPy and Pythonโno hidden layers, no cryptic C extensions, just clean, readable code that helps you understand what's really happening under the hood.
| Students & Learners | Data Scientists | Researchers | Educators |
|---|---|---|---|
| Pure Python code you can actually read | Tabular-first with DataFrame support | Reproducible & well-documented | Perfect teaching tool |
|
Every algorithm written in pure NumPy/Python. Open any file and understand exactly how the math works. No black boxes, no magic. |
Built-in safeguards catch common mistakes before they become bugs. Data leakage? Wrong evaluation? Missing random state? We've got you covered. |
Real data comes in CSVs and DataFrames. NumEdge handles mixed types, preprocessing, and encoding automaticallyโno pipelines required. |
# Clone the repository
git clone https://github.com/Nitin-Prata/numedge.git
cd numedge
# Install in development mode
pip install -e .๐ฆ Coming Soon:
pip install numedge
Requirements:
- Python 3.8 or higher
- NumPy (core dependency)
- pandas (optional, for tabular features)
from numedge.models.linear_models import LinearRegression
from numedge.model_selection import train_test_split
import numpy as np
# Generate sample data
X = np.random.randn(1000, 5)
y = X @ np.array([1.5, -2.0, 0.5, 3.0, -1.0]) + np.random.randn(1000) * 0.1
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train model
model = LinearRegression()
model.fit(X_train, y_train)
# Evaluate
print(f"Training Rยฒ: {model.score(X_train, y_train):.4f}")
print(f"Testing Rยฒ: {model.score(X_test, y_test):.4f}")
# Make predictions
predictions = model.predict(X_test)from numedge.models.ensemble import RandomForestClassifier
from numedge.model_selection import GridSearchCV
# Create model
rf = RandomForestClassifier(random_state=42)
# Get recommended hyperparameter search space
search_space = rf.get_search_space()
print(f"Recommended search space: {search_space}")
# Perform grid search
grid_search = GridSearchCV(
estimator=rf,
param_grid=search_space,
cv=5,
scoring='accuracy'
)
grid_search.fit(X_train, y_train)
# Best model
best_model = grid_search.best_estimator_
print(f"Best parameters: {grid_search.best_params_}")
print(f"Best CV score: {grid_search.best_score_:.4f}")import pandas as pd
from numedge.tabular import TabularClassifier
from numedge.models.ensemble import GradientBoostingClassifier
# Your real-world DataFrame with mixed types
df = pd.DataFrame({
'age': [25, 35, 45, 22, 55],
'income': [50000, 75000, 90000, 45000, 120000],
'city': ['NYC', 'LA', 'NYC', 'Chicago', 'LA'],
'education': ['Bachelor', 'Master', 'PhD', 'Bachelor', 'Master'],
'purchased': [0, 1, 1, 0, 1]
})
# Create tabular classifier
model = TabularClassifier(
estimator=GradientBoostingClassifier(random_state=42),
target='purchased'
)
# NumEdge automatically:
# โ
Detects numeric vs categorical columns
# โ
Scales numeric features
# โ
One-hot encodes categorical features
# โ
Handles train/test consistency
model.fit(df)
predictions = model.predict(df)from numedge.cluster import KMeans
import matplotlib.pyplot as plt
# Create clusters
kmeans = KMeans(n_clusters=3, random_state=42)
kmeans.fit(X)
# Get cluster assignments
labels = kmeans.predict(X)
centers = kmeans.cluster_centers_
# Visualize
plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.6)
plt.scatter(centers[:, 0], centers[:, 1], c='red', marker='X', s=200, edgecolors='black')
plt.title('K-Means Clustering')
plt.show()from numedge.models.linear_models import SGDRegressor
# Initialize model
model = SGDRegressor(learning_rate=0.01)
# Learn from data in batches (useful for large datasets)
for batch_X, batch_y in data_stream:
model.partial_fit(batch_X, batch_y)
# Final predictions
final_predictions = model.predict(X_test)๐ Supervised Learning
Linear Models
LinearRegressionโ Ordinary least squaresRidgeโ L2 regularized regressionLassoโ L1 regularized regressionElasticNetโ Combined L1 + L2 regularizationLogisticRegressionโ Binary & multiclass classificationSGDRegressorโ Stochastic gradient descent regressionSGDClassifierโ Stochastic gradient descent classification
Tree-Based Models
DecisionTreeClassifierโ CART algorithmDecisionTreeRegressorโ Regression treesRandomForestClassifierโ Ensemble of decision treesRandomForestRegressorโ Ensemble for regressionExtraTreesClassifierโ Extremely randomized treesExtraTreesRegressorโ Extra trees for regression
Ensemble Methods
GradientBoostingClassifierโ Gradient boostingGradientBoostingRegressorโ Boosting for regressionAdaBoostClassifierโ Adaptive boostingAdaBoostRegressorโ AdaBoost for regressionBaggingClassifierโ Bootstrap aggregatingBaggingRegressorโ Bagging for regression
Support Vector Machines
SVCโ Support vector classificationSVRโ Support vector regression
Neighbors
KNeighborsClassifierโ K-nearest neighbors classificationKNeighborsRegressorโ K-nearest neighbors regression
Naive Bayes
GaussianNBโ Gaussian Naive BayesMultinomialNBโ Multinomial Naive Bayes
Advanced Boosting
XGBClassifierโ NumPy-based XGBoost implementationXGBRegressorโ XGBoost for regression
๐ Unsupervised Learning
Clustering
KMeansโ K-means clusteringDBSCANโ Density-based clusteringAgglomerativeClusteringโ Hierarchical clustering
Dimensionality Reduction
PCAโ Principal component analysis
โ๏ธ Preprocessing & Utilities
Scalers
StandardScalerโ Standardize features (zero mean, unit variance)MinMaxScalerโ Scale features to a rangeRobustScalerโ Scale using median and IQR
Encoders
OneHotEncoderโ One-hot encode categorical featuresLabelEncoderโ Encode labels as integers
Model Selection
train_test_splitโ Split data into train/test setscross_val_scoreโ K-fold cross-validationGridSearchCVโ Exhaustive hyperparameter searchRandomizedSearchCVโ Randomized hyperparameter search
Metrics
- Classification:
accuracy,precision,recall,f1_score,roc_auc - Regression:
r2_score,mse,mae,rmse
numedge/
โ
โโโ ๐ src/numedge/
โ โ
โ โโโ ๐ฏ core/ # Base classes, mixins, optimizers
โ โ โโโ base.py # BaseEstimator
โ โ โโโ mixins.py # ClassifierMixin, RegressorMixin
โ โ โโโ optimizers.py # Gradient descent variants
โ โ
โ โโโ ๐ค models/ # All supervised algorithms
โ โ โโโ linear_models/ # Linear regression, Ridge, Lasso, etc.
โ โ โโโ ensemble/ # Random Forest, Boosting, Bagging
โ โ โโโ tree/ # Decision Trees
โ โ โโโ svm/ # Support Vector Machines
โ โ โโโ neighbors/ # K-Nearest Neighbors
โ โ โโโ naive_bayes/ # Naive Bayes variants
โ โ
โ โโโ ๐ cluster/ # Clustering algorithms
โ โ โโโ kmeans.py
โ โ โโโ dbscan.py
โ โ โโโ hierarchical.py
โ โ
โ โโโ ๐ decomposition/ # Dimensionality reduction
โ โ โโโ pca.py
โ โ
โ โโโ โ๏ธ preprocessing/ # Data transformers
โ โ โโโ scalers.py
โ โ โโโ encoders.py
โ โ
โ โโโ ๐ฒ model_selection/ # CV, search, split utilities
โ โ โโโ split.py
โ โ โโโ cross_validation.py
โ โ โโโ search.py
โ โ
โ โโโ ๐ metrics/ # Evaluation metrics
โ โ โโโ classification.py
โ โ โโโ regression.py
โ โ
โ โโโ ๐ tabular/ # DataFrame helpers
โ โ โโโ classifier.py
โ โ โโโ regressor.py
โ โ
โ โโโ ๐ ๏ธ utils/ # Internal utilities
โ โโโ validation.py
โ โโโ checks.py
โ โโโ warnings.py
โ
โโโ ๐งช tests/ # Comprehensive test suite
โโโ ๐ examples/ # Jupyter notebooks & tutorials
โโโ ๐ docs/ # Documentation (coming soon)
โโโ ๐ README.md # You are here!
|
|
NumEdge is actively developed and we'd love your help!
- ๐ Report Bugs โ Found an issue? Open an issue
- ๐ก Suggest Features โ Have ideas? Start a discussion
- ๐ Improve Docs โ Better explanations, examples, tutorials
- โจ Submit Code โ New algorithms, optimizations, fixes
- โญ Star the Repo โ Show your support!
Before contributing code, please read our Contributing Guidelines.
NumEdge is open-source software licensed under the MIT License.
See the LICENSE file for full details.
NumEdge stands on the shoulders of giants. Inspired by the open-source ML community and driven by a passion for transparent, educational tools.
Special thanks to everyone who believes that understanding how things work is just as important as making them work.
If NumEdge helps you learn or build something awesome, please consider starring the repo!
โญ Star โข ๐ด Fork โข ๐ฃ Share
๐ Report Bug โข โจ Request Feature โข ๐ฌ Discuss
NumEdge โ Machine Learning That Makes Sense