Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

ย 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ NumEdge

Machine Learning That Makes Sense

Python 3.8+ MIT License NumPy PRs Welcome

A lightweight, intelligent machine learning library built on pure NumPy

Where transparency meets power, and learning meets doing




๐ŸŒŸ Why NumEdge Exists

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.

๐ŸŽ“ Built For

Students & Learners Data Scientists Researchers Educators
Pure Python code you can actually read Tabular-first with DataFrame support Reproducible & well-documented Perfect teaching tool



โœจ Core Philosophy

๐Ÿ” Transparent by Design

Every algorithm written in pure NumPy/Python. Open any file and understand exactly how the math works. No black boxes, no magic.

๐Ÿ›ก๏ธ Intelligent Warnings

Built-in safeguards catch common mistakes before they become bugs. Data leakage? Wrong evaluation? Missing random state? We've got you covered.

๐Ÿ“Š Tabular-First

Real data comes in CSVs and DataFrames. NumEdge handles mixed types, preprocessing, and encoding automaticallyโ€”no pipelines required.


๐ŸŽฏ Readable over Fast โ€ข Understanding over Optimization โ€ข Clarity over Complexity




๐Ÿš€ Quick Start

Installation

# 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)



๐Ÿ’ก Examples

๐Ÿ”น Linear Regression

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)

๐Ÿ”น Random Forest with Hyperparameter Search

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}")

๐Ÿ”น Tabular Data (DataFrames)

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)

๐Ÿ”น K-Means Clustering

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()

๐Ÿ”น Incremental Learning (Streaming)

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)



๐Ÿง  Available Algorithms

๐Ÿ“ˆ Supervised Learning

Linear Models

  • LinearRegression โ€” Ordinary least squares
  • Ridge โ€” L2 regularized regression
  • Lasso โ€” L1 regularized regression
  • ElasticNet โ€” Combined L1 + L2 regularization
  • LogisticRegression โ€” Binary & multiclass classification
  • SGDRegressor โ€” Stochastic gradient descent regression
  • SGDClassifier โ€” Stochastic gradient descent classification

Tree-Based Models

  • DecisionTreeClassifier โ€” CART algorithm
  • DecisionTreeRegressor โ€” Regression trees
  • RandomForestClassifier โ€” Ensemble of decision trees
  • RandomForestRegressor โ€” Ensemble for regression
  • ExtraTreesClassifier โ€” Extremely randomized trees
  • ExtraTreesRegressor โ€” Extra trees for regression

Ensemble Methods

  • GradientBoostingClassifier โ€” Gradient boosting
  • GradientBoostingRegressor โ€” Boosting for regression
  • AdaBoostClassifier โ€” Adaptive boosting
  • AdaBoostRegressor โ€” AdaBoost for regression
  • BaggingClassifier โ€” Bootstrap aggregating
  • BaggingRegressor โ€” Bagging for regression

Support Vector Machines

  • SVC โ€” Support vector classification
  • SVR โ€” Support vector regression

Neighbors

  • KNeighborsClassifier โ€” K-nearest neighbors classification
  • KNeighborsRegressor โ€” K-nearest neighbors regression

Naive Bayes

  • GaussianNB โ€” Gaussian Naive Bayes
  • MultinomialNB โ€” Multinomial Naive Bayes

Advanced Boosting

  • XGBClassifier โ€” NumPy-based XGBoost implementation
  • XGBRegressor โ€” XGBoost for regression
๐Ÿ” Unsupervised Learning

Clustering

  • KMeans โ€” K-means clustering
  • DBSCAN โ€” Density-based clustering
  • AgglomerativeClustering โ€” Hierarchical clustering

Dimensionality Reduction

  • PCA โ€” Principal component analysis
โš™๏ธ Preprocessing & Utilities

Scalers

  • StandardScaler โ€” Standardize features (zero mean, unit variance)
  • MinMaxScaler โ€” Scale features to a range
  • RobustScaler โ€” Scale using median and IQR

Encoders

  • OneHotEncoder โ€” One-hot encode categorical features
  • LabelEncoder โ€” Encode labels as integers

Model Selection

  • train_test_split โ€” Split data into train/test sets
  • cross_val_score โ€” K-fold cross-validation
  • GridSearchCV โ€” Exhaustive hyperparameter search
  • RandomizedSearchCV โ€” Randomized hyperparameter search

Metrics

  • Classification: accuracy, precision, recall, f1_score, roc_auc
  • Regression: r2_score, mse, mae, rmse



๐Ÿ“ Project Structure

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!



๐Ÿ—บ๏ธ Roadmap

โœ… Current Focus

  • Core algorithms implementation
  • Tabular data support
  • Hyperparameter search spaces
  • Intelligent warning system
  • Complete test coverage (>90%)
  • Performance benchmarks

๐Ÿ”ฎ Coming Soon

  • Full documentation site
  • PyPI release
  • Interactive tutorials
  • More ensemble methods
  • Advanced feature engineering
  • CI/CD pipeline



๐Ÿค Contributing

NumEdge is actively developed and we'd love your help!

๐ŸŒŸ Ways to Contribute

  • ๐Ÿ› 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.




๐Ÿ“„ License

NumEdge is open-source software licensed under the MIT License.

See the LICENSE file for full details.




๐Ÿ‘จโ€๐Ÿ’ป Creator

Nitin Pratap Singh

GitHub LinkedIn X Email




๐Ÿ™ Acknowledgments

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.




๐Ÿ’– Made with passion for the ML community

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

About

A lightweight, NumPy-powered machine learning library built from scratch. simple and clean

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors