simpleml-auronss 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simpleml_auronss-0.1.0/LICENSE +19 -0
- simpleml_auronss-0.1.0/PKG-INFO +276 -0
- simpleml_auronss-0.1.0/README.md +248 -0
- simpleml_auronss-0.1.0/pyproject.toml +50 -0
- simpleml_auronss-0.1.0/setup.cfg +4 -0
- simpleml_auronss-0.1.0/simpleml/__init__.py +41 -0
- simpleml_auronss-0.1.0/simpleml/base.py +100 -0
- simpleml_auronss-0.1.0/simpleml/cluster.py +270 -0
- simpleml_auronss-0.1.0/simpleml/ensemble.py +193 -0
- simpleml_auronss-0.1.0/simpleml/linear_model.py +192 -0
- simpleml_auronss-0.1.0/simpleml/metrics.py +235 -0
- simpleml_auronss-0.1.0/simpleml/model_selection.py +211 -0
- simpleml_auronss-0.1.0/simpleml/naive_bayes.py +178 -0
- simpleml_auronss-0.1.0/simpleml/preprocessing.py +222 -0
- simpleml_auronss-0.1.0/simpleml/svm.py +197 -0
- simpleml_auronss-0.1.0/simpleml/tree.py +336 -0
- simpleml_auronss-0.1.0/simpleml/utils.py +160 -0
- simpleml_auronss-0.1.0/simpleml_auronss.egg-info/PKG-INFO +276 -0
- simpleml_auronss-0.1.0/simpleml_auronss.egg-info/SOURCES.txt +30 -0
- simpleml_auronss-0.1.0/simpleml_auronss.egg-info/dependency_links.txt +1 -0
- simpleml_auronss-0.1.0/simpleml_auronss.egg-info/requires.txt +5 -0
- simpleml_auronss-0.1.0/simpleml_auronss.egg-info/top_level.txt +3 -0
- simpleml_auronss-0.1.0/tests/__init__.py +1 -0
- simpleml_auronss-0.1.0/tests/test_clustering.py +43 -0
- simpleml_auronss-0.1.0/tests/test_ensemble.py +45 -0
- simpleml_auronss-0.1.0/tests/test_linear_model.py +60 -0
- simpleml_auronss-0.1.0/tests/test_metrics.py +83 -0
- simpleml_auronss-0.1.0/tests/test_model_selection.py +58 -0
- simpleml_auronss-0.1.0/tests/test_naive_bayes.py +35 -0
- simpleml_auronss-0.1.0/tests/test_preprocessing.py +63 -0
- simpleml_auronss-0.1.0/tests/test_svm.py +38 -0
- simpleml_auronss-0.1.0/tests/test_tree.py +50 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 Serge Auronss Gbaguidi
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simpleml-auronss
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight, educational scikit-learn-like machine learning library
|
|
5
|
+
Author: Serge Auronss Gbaguidi
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/auronssms/simpleml
|
|
8
|
+
Project-URL: Repository, https://github.com/auronssms/simpleml
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.7
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: numpy>=1.19.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# simpleml
|
|
30
|
+
|
|
31
|
+
A lightweight, educational implementation of a scikit-learn-like machine learning library in pure Python and NumPy.
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **Classification Models**: Logistic Regression, Decision Trees, Random Forests, Naive Bayes, Support Vector Classifiers
|
|
36
|
+
- **Regression Models**: Linear Regression, Decision Tree Regression, Random Forest Regression, Support Vector Regression
|
|
37
|
+
- **Clustering Algorithms**: K-Means, DBSCAN
|
|
38
|
+
- **Preprocessing**: StandardScaler, MinMaxScaler, OneHotEncoder
|
|
39
|
+
- **Model Selection**: K-Fold Cross-Validation, Grid Search, Cross-Validation
|
|
40
|
+
- **Metrics**: Accuracy, Precision, Recall, F1-Score, Confusion Matrix, MSE, MAE, R² Score
|
|
41
|
+
- **Consistent API**: Inspired by scikit-learn's fit-predict interface
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/sergeauronss01/simpleml.git
|
|
47
|
+
cd simpleml
|
|
48
|
+
pip install -r requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### Basic Classification
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from simpleml.linear_model import LogisticRegression
|
|
57
|
+
from simpleml.preprocessing import StandardScaler
|
|
58
|
+
from simpleml.model_selection import train_test_split
|
|
59
|
+
from simpleml.metrics import accuracy_score
|
|
60
|
+
import numpy as np
|
|
61
|
+
|
|
62
|
+
# Generate sample data
|
|
63
|
+
X = np.random.randn(100, 5)
|
|
64
|
+
y = np.random.randint(0, 2, 100)
|
|
65
|
+
|
|
66
|
+
# Split data
|
|
67
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
68
|
+
|
|
69
|
+
# Preprocess
|
|
70
|
+
scaler = StandardScaler()
|
|
71
|
+
X_train = scaler.fit_transform(X_train)
|
|
72
|
+
X_test = scaler.transform(X_test)
|
|
73
|
+
|
|
74
|
+
# Train model
|
|
75
|
+
clf = LogisticRegression(n_iterations=1000)
|
|
76
|
+
clf.fit(X_train, y_train)
|
|
77
|
+
|
|
78
|
+
# Evaluate
|
|
79
|
+
y_pred = clf.predict(X_test)
|
|
80
|
+
print(f"Accuracy: {accuracy_score(y_test, y_pred)}")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Decision Tree Classifier
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from simpleml.tree import DecisionTreeClassifier
|
|
87
|
+
|
|
88
|
+
X = np.array([[0, 0], [1, 1], [0, 1], [1, 0]])
|
|
89
|
+
y = np.array([0, 1, 1, 0])
|
|
90
|
+
|
|
91
|
+
clf = DecisionTreeClassifier(max_depth=3)
|
|
92
|
+
clf.fit(X, y)
|
|
93
|
+
predictions = clf.predict(X)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Random Forest
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from simpleml.ensemble import RandomForestClassifier
|
|
100
|
+
|
|
101
|
+
clf = RandomForestClassifier(n_estimators=10, random_state=42)
|
|
102
|
+
clf.fit(X_train, y_train)
|
|
103
|
+
predictions = clf.predict(X_test)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### K-Means Clustering
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from simpleml.cluster import KMeans
|
|
110
|
+
|
|
111
|
+
kmeans = KMeans(n_clusters=3, random_state=42)
|
|
112
|
+
kmeans.fit(X)
|
|
113
|
+
labels = kmeans.predict(X_new)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Cross-Validation
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from simpleml.model_selection import cross_validate
|
|
120
|
+
|
|
121
|
+
scores = cross_validate(clf, X, y, cv=5)
|
|
122
|
+
print(f"Mean test score: {scores['mean_test_score']}")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Grid Search
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from simpleml.model_selection import GridSearchCV
|
|
129
|
+
|
|
130
|
+
param_grid = {
|
|
131
|
+
'learning_rate': [0.01, 0.1],
|
|
132
|
+
'n_iterations': [100, 500],
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
gs = GridSearchCV(clf, param_grid, cv=5)
|
|
136
|
+
gs.fit(X_train, y_train)
|
|
137
|
+
print(f"Best parameters: {gs.best_params_}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Module Structure
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
simpleml/
|
|
144
|
+
├── __init__.py # Package initialization
|
|
145
|
+
├── base.py # Base classes (BaseEstimator, ClassifierMixin, etc.)
|
|
146
|
+
├── linear_model.py # Linear regression and classification
|
|
147
|
+
├── tree.py # Decision tree models
|
|
148
|
+
├── ensemble.py # Ensemble methods
|
|
149
|
+
├── cluster.py # Clustering algorithms
|
|
150
|
+
├── naive_bayes.py # Naive Bayes classifiers
|
|
151
|
+
├── svm.py # Support Vector Machines
|
|
152
|
+
├── preprocessing.py # Data preprocessing
|
|
153
|
+
├── model_selection.py # Model selection and evaluation
|
|
154
|
+
├── metrics.py # Evaluation metrics
|
|
155
|
+
└── utils.py # Utility functions
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Available Models
|
|
159
|
+
|
|
160
|
+
### Supervised Learning
|
|
161
|
+
|
|
162
|
+
#### Classification
|
|
163
|
+
- `LogisticRegression`: Binary logistic regression with gradient descent
|
|
164
|
+
- `DecisionTreeClassifier`: Decision tree with Gini/Entropy splits
|
|
165
|
+
- `RandomForestClassifier`: Ensemble of decision trees
|
|
166
|
+
- `GaussianNaiveBayes`: Gaussian Naive Bayes classifier
|
|
167
|
+
- `MultinomialNaiveBayes`: Multinomial Naive Bayes for discrete features
|
|
168
|
+
- `LinearSVC`: Linear Support Vector Classifier
|
|
169
|
+
|
|
170
|
+
#### Regression
|
|
171
|
+
- `LinearRegression`: Ordinary least squares regression
|
|
172
|
+
- `DecisionTreeRegressor`: Decision tree regression
|
|
173
|
+
- `RandomForestRegressor`: Ensemble regression
|
|
174
|
+
- `SVR`: Support Vector Regression
|
|
175
|
+
|
|
176
|
+
### Unsupervised Learning
|
|
177
|
+
|
|
178
|
+
#### Clustering
|
|
179
|
+
- `KMeans`: K-Means clustering algorithm
|
|
180
|
+
- `DBSCAN`: Density-based clustering
|
|
181
|
+
|
|
182
|
+
### Preprocessing
|
|
183
|
+
|
|
184
|
+
- `StandardScaler`: Standardization (zero mean, unit variance)
|
|
185
|
+
- `MinMaxScaler`: Min-Max scaling to a fixed range
|
|
186
|
+
- `OneHotEncoder`: One-hot encoding for categorical features
|
|
187
|
+
|
|
188
|
+
### Model Selection
|
|
189
|
+
|
|
190
|
+
- `KFold`: K-Fold cross-validator
|
|
191
|
+
- `cross_validate()`: Cross-validation scoring
|
|
192
|
+
- `GridSearchCV`: Exhaustive grid search
|
|
193
|
+
|
|
194
|
+
## Metrics
|
|
195
|
+
|
|
196
|
+
All metrics are available in `simpleml.metrics`:
|
|
197
|
+
|
|
198
|
+
- `accuracy_score`: Classification accuracy
|
|
199
|
+
- `precision_score`: Precision for binary classification
|
|
200
|
+
- `recall_score`: Recall for binary classification
|
|
201
|
+
- `f1_score`: F1-Score for binary classification
|
|
202
|
+
- `confusion_matrix`: Confusion matrix
|
|
203
|
+
- `mean_squared_error`: Mean squared error
|
|
204
|
+
- `mean_absolute_error`: Mean absolute error
|
|
205
|
+
- `r2_score`: R² coefficient of determination
|
|
206
|
+
|
|
207
|
+
## Testing
|
|
208
|
+
|
|
209
|
+
Run the test suite:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
pytest tests/ -v
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Run tests with coverage:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pytest tests/ --cov=simpleml
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Documentation
|
|
222
|
+
|
|
223
|
+
Each module is thoroughly documented with docstrings following NumPy style. Use `help()` in Python:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from simpleml.linear_model import LogisticRegression
|
|
227
|
+
help(LogisticRegression)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Design Philosophy
|
|
231
|
+
|
|
232
|
+
This library is designed to:
|
|
233
|
+
|
|
234
|
+
1. **Educate**: Clear, understandable implementations without external ML dependencies
|
|
235
|
+
2. **Mirror scikit-learn**: Familiar API for users of scikit-learn
|
|
236
|
+
3. **Be extensible**: Easy to add new models and algorithms
|
|
237
|
+
4. **Be tested**: Comprehensive test coverage
|
|
238
|
+
|
|
239
|
+
## Limitations
|
|
240
|
+
|
|
241
|
+
- No support for neural networks or deep learning
|
|
242
|
+
- No GPU acceleration
|
|
243
|
+
- Limited to basic algorithms (no advanced techniques like stacking, boosting beyond basic implementation)
|
|
244
|
+
- Not optimized for large-scale datasets
|
|
245
|
+
|
|
246
|
+
## Performance
|
|
247
|
+
|
|
248
|
+
This library is for educational purposes. For production use and performance-critical applications, use scikit-learn or similar production libraries.
|
|
249
|
+
|
|
250
|
+
## Contributing
|
|
251
|
+
|
|
252
|
+
To contribute:
|
|
253
|
+
|
|
254
|
+
1. Fork the repository
|
|
255
|
+
2. Create a feature branch
|
|
256
|
+
3. Write tests for new functionality
|
|
257
|
+
4. Ensure all tests pass
|
|
258
|
+
5. Submit a pull request
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT License
|
|
263
|
+
|
|
264
|
+
## Author
|
|
265
|
+
|
|
266
|
+
Serge Auronss Gbaguidi
|
|
267
|
+
|
|
268
|
+
## References
|
|
269
|
+
|
|
270
|
+
- Scikit-learn documentation: https://scikit-learn.org
|
|
271
|
+
- NumPy documentation: https://numpy.org
|
|
272
|
+
- Machine Learning fundamentals
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
**Note**: This is an educational project created to understand machine learning algorithms and best practices for library design. For production machine learning work, please use [scikit-learn](https://scikit-learn.org/).
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# simpleml
|
|
2
|
+
|
|
3
|
+
A lightweight, educational implementation of a scikit-learn-like machine learning library in pure Python and NumPy.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Classification Models**: Logistic Regression, Decision Trees, Random Forests, Naive Bayes, Support Vector Classifiers
|
|
8
|
+
- **Regression Models**: Linear Regression, Decision Tree Regression, Random Forest Regression, Support Vector Regression
|
|
9
|
+
- **Clustering Algorithms**: K-Means, DBSCAN
|
|
10
|
+
- **Preprocessing**: StandardScaler, MinMaxScaler, OneHotEncoder
|
|
11
|
+
- **Model Selection**: K-Fold Cross-Validation, Grid Search, Cross-Validation
|
|
12
|
+
- **Metrics**: Accuracy, Precision, Recall, F1-Score, Confusion Matrix, MSE, MAE, R² Score
|
|
13
|
+
- **Consistent API**: Inspired by scikit-learn's fit-predict interface
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/sergeauronss01/simpleml.git
|
|
19
|
+
cd simpleml
|
|
20
|
+
pip install -r requirements.txt
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Basic Classification
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from simpleml.linear_model import LogisticRegression
|
|
29
|
+
from simpleml.preprocessing import StandardScaler
|
|
30
|
+
from simpleml.model_selection import train_test_split
|
|
31
|
+
from simpleml.metrics import accuracy_score
|
|
32
|
+
import numpy as np
|
|
33
|
+
|
|
34
|
+
# Generate sample data
|
|
35
|
+
X = np.random.randn(100, 5)
|
|
36
|
+
y = np.random.randint(0, 2, 100)
|
|
37
|
+
|
|
38
|
+
# Split data
|
|
39
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
40
|
+
|
|
41
|
+
# Preprocess
|
|
42
|
+
scaler = StandardScaler()
|
|
43
|
+
X_train = scaler.fit_transform(X_train)
|
|
44
|
+
X_test = scaler.transform(X_test)
|
|
45
|
+
|
|
46
|
+
# Train model
|
|
47
|
+
clf = LogisticRegression(n_iterations=1000)
|
|
48
|
+
clf.fit(X_train, y_train)
|
|
49
|
+
|
|
50
|
+
# Evaluate
|
|
51
|
+
y_pred = clf.predict(X_test)
|
|
52
|
+
print(f"Accuracy: {accuracy_score(y_test, y_pred)}")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Decision Tree Classifier
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from simpleml.tree import DecisionTreeClassifier
|
|
59
|
+
|
|
60
|
+
X = np.array([[0, 0], [1, 1], [0, 1], [1, 0]])
|
|
61
|
+
y = np.array([0, 1, 1, 0])
|
|
62
|
+
|
|
63
|
+
clf = DecisionTreeClassifier(max_depth=3)
|
|
64
|
+
clf.fit(X, y)
|
|
65
|
+
predictions = clf.predict(X)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Random Forest
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from simpleml.ensemble import RandomForestClassifier
|
|
72
|
+
|
|
73
|
+
clf = RandomForestClassifier(n_estimators=10, random_state=42)
|
|
74
|
+
clf.fit(X_train, y_train)
|
|
75
|
+
predictions = clf.predict(X_test)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### K-Means Clustering
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from simpleml.cluster import KMeans
|
|
82
|
+
|
|
83
|
+
kmeans = KMeans(n_clusters=3, random_state=42)
|
|
84
|
+
kmeans.fit(X)
|
|
85
|
+
labels = kmeans.predict(X_new)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Cross-Validation
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from simpleml.model_selection import cross_validate
|
|
92
|
+
|
|
93
|
+
scores = cross_validate(clf, X, y, cv=5)
|
|
94
|
+
print(f"Mean test score: {scores['mean_test_score']}")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Grid Search
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from simpleml.model_selection import GridSearchCV
|
|
101
|
+
|
|
102
|
+
param_grid = {
|
|
103
|
+
'learning_rate': [0.01, 0.1],
|
|
104
|
+
'n_iterations': [100, 500],
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
gs = GridSearchCV(clf, param_grid, cv=5)
|
|
108
|
+
gs.fit(X_train, y_train)
|
|
109
|
+
print(f"Best parameters: {gs.best_params_}")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Module Structure
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
simpleml/
|
|
116
|
+
├── __init__.py # Package initialization
|
|
117
|
+
├── base.py # Base classes (BaseEstimator, ClassifierMixin, etc.)
|
|
118
|
+
├── linear_model.py # Linear regression and classification
|
|
119
|
+
├── tree.py # Decision tree models
|
|
120
|
+
├── ensemble.py # Ensemble methods
|
|
121
|
+
├── cluster.py # Clustering algorithms
|
|
122
|
+
├── naive_bayes.py # Naive Bayes classifiers
|
|
123
|
+
├── svm.py # Support Vector Machines
|
|
124
|
+
├── preprocessing.py # Data preprocessing
|
|
125
|
+
├── model_selection.py # Model selection and evaluation
|
|
126
|
+
├── metrics.py # Evaluation metrics
|
|
127
|
+
└── utils.py # Utility functions
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Available Models
|
|
131
|
+
|
|
132
|
+
### Supervised Learning
|
|
133
|
+
|
|
134
|
+
#### Classification
|
|
135
|
+
- `LogisticRegression`: Binary logistic regression with gradient descent
|
|
136
|
+
- `DecisionTreeClassifier`: Decision tree with Gini/Entropy splits
|
|
137
|
+
- `RandomForestClassifier`: Ensemble of decision trees
|
|
138
|
+
- `GaussianNaiveBayes`: Gaussian Naive Bayes classifier
|
|
139
|
+
- `MultinomialNaiveBayes`: Multinomial Naive Bayes for discrete features
|
|
140
|
+
- `LinearSVC`: Linear Support Vector Classifier
|
|
141
|
+
|
|
142
|
+
#### Regression
|
|
143
|
+
- `LinearRegression`: Ordinary least squares regression
|
|
144
|
+
- `DecisionTreeRegressor`: Decision tree regression
|
|
145
|
+
- `RandomForestRegressor`: Ensemble regression
|
|
146
|
+
- `SVR`: Support Vector Regression
|
|
147
|
+
|
|
148
|
+
### Unsupervised Learning
|
|
149
|
+
|
|
150
|
+
#### Clustering
|
|
151
|
+
- `KMeans`: K-Means clustering algorithm
|
|
152
|
+
- `DBSCAN`: Density-based clustering
|
|
153
|
+
|
|
154
|
+
### Preprocessing
|
|
155
|
+
|
|
156
|
+
- `StandardScaler`: Standardization (zero mean, unit variance)
|
|
157
|
+
- `MinMaxScaler`: Min-Max scaling to a fixed range
|
|
158
|
+
- `OneHotEncoder`: One-hot encoding for categorical features
|
|
159
|
+
|
|
160
|
+
### Model Selection
|
|
161
|
+
|
|
162
|
+
- `KFold`: K-Fold cross-validator
|
|
163
|
+
- `cross_validate()`: Cross-validation scoring
|
|
164
|
+
- `GridSearchCV`: Exhaustive grid search
|
|
165
|
+
|
|
166
|
+
## Metrics
|
|
167
|
+
|
|
168
|
+
All metrics are available in `simpleml.metrics`:
|
|
169
|
+
|
|
170
|
+
- `accuracy_score`: Classification accuracy
|
|
171
|
+
- `precision_score`: Precision for binary classification
|
|
172
|
+
- `recall_score`: Recall for binary classification
|
|
173
|
+
- `f1_score`: F1-Score for binary classification
|
|
174
|
+
- `confusion_matrix`: Confusion matrix
|
|
175
|
+
- `mean_squared_error`: Mean squared error
|
|
176
|
+
- `mean_absolute_error`: Mean absolute error
|
|
177
|
+
- `r2_score`: R² coefficient of determination
|
|
178
|
+
|
|
179
|
+
## Testing
|
|
180
|
+
|
|
181
|
+
Run the test suite:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
pytest tests/ -v
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Run tests with coverage:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pytest tests/ --cov=simpleml
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Documentation
|
|
194
|
+
|
|
195
|
+
Each module is thoroughly documented with docstrings following NumPy style. Use `help()` in Python:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from simpleml.linear_model import LogisticRegression
|
|
199
|
+
help(LogisticRegression)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Design Philosophy
|
|
203
|
+
|
|
204
|
+
This library is designed to:
|
|
205
|
+
|
|
206
|
+
1. **Educate**: Clear, understandable implementations without external ML dependencies
|
|
207
|
+
2. **Mirror scikit-learn**: Familiar API for users of scikit-learn
|
|
208
|
+
3. **Be extensible**: Easy to add new models and algorithms
|
|
209
|
+
4. **Be tested**: Comprehensive test coverage
|
|
210
|
+
|
|
211
|
+
## Limitations
|
|
212
|
+
|
|
213
|
+
- No support for neural networks or deep learning
|
|
214
|
+
- No GPU acceleration
|
|
215
|
+
- Limited to basic algorithms (no advanced techniques like stacking, boosting beyond basic implementation)
|
|
216
|
+
- Not optimized for large-scale datasets
|
|
217
|
+
|
|
218
|
+
## Performance
|
|
219
|
+
|
|
220
|
+
This library is for educational purposes. For production use and performance-critical applications, use scikit-learn or similar production libraries.
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
To contribute:
|
|
225
|
+
|
|
226
|
+
1. Fork the repository
|
|
227
|
+
2. Create a feature branch
|
|
228
|
+
3. Write tests for new functionality
|
|
229
|
+
4. Ensure all tests pass
|
|
230
|
+
5. Submit a pull request
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT License
|
|
235
|
+
|
|
236
|
+
## Author
|
|
237
|
+
|
|
238
|
+
Serge Auronss Gbaguidi
|
|
239
|
+
|
|
240
|
+
## References
|
|
241
|
+
|
|
242
|
+
- Scikit-learn documentation: https://scikit-learn.org
|
|
243
|
+
- NumPy documentation: https://numpy.org
|
|
244
|
+
- Machine Learning fundamentals
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
**Note**: This is an educational project created to understand machine learning algorithms and best practices for library design. For production machine learning work, please use [scikit-learn](https://scikit-learn.org/).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "simpleml-auronss"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A lightweight, educational scikit-learn-like machine learning library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Serge Auronss Gbaguidi" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.7",
|
|
18
|
+
"Programming Language :: Python :: 3.8",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Intended Audience :: Education",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"numpy>=1.19.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
"Homepage" = "https://github.com/auronssms/simpleml"
|
|
34
|
+
"Repository" = "https://github.com/auronssms/simpleml"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"pytest>=6.0.0",
|
|
39
|
+
"pytest-cov>=2.10.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
where = ["."]
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
minversion = "6.0"
|
|
47
|
+
addopts = "-ra -q --cov=simpleml"
|
|
48
|
+
testpaths = [
|
|
49
|
+
"tests",
|
|
50
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
sklearn-lite: A lightweight machine learning library inspired by scikit-learn.
|
|
3
|
+
|
|
4
|
+
Modules:
|
|
5
|
+
tree: Decision tree models
|
|
6
|
+
linear_model: Linear regression and classification models
|
|
7
|
+
svm: Support Vector Machines
|
|
8
|
+
ensemble: Ensemble methods
|
|
9
|
+
naive_bayes: Naive Bayes classifiers
|
|
10
|
+
cluster: Clustering algorithms
|
|
11
|
+
preprocessing: Data preprocessing utilities
|
|
12
|
+
model_selection: Model selection and evaluation tools
|
|
13
|
+
metrics: Metrics for model evaluation
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
__version__ = "0.1.0"
|
|
17
|
+
__author__ = "sergeauronss01"
|
|
18
|
+
|
|
19
|
+
from . import (
|
|
20
|
+
tree,
|
|
21
|
+
linear_model,
|
|
22
|
+
svm,
|
|
23
|
+
ensemble,
|
|
24
|
+
naive_bayes,
|
|
25
|
+
cluster,
|
|
26
|
+
preprocessing,
|
|
27
|
+
model_selection,
|
|
28
|
+
metrics,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"tree",
|
|
33
|
+
"linear_model",
|
|
34
|
+
"svm",
|
|
35
|
+
"ensemble",
|
|
36
|
+
"naive_bayes",
|
|
37
|
+
"cluster",
|
|
38
|
+
"preprocessing",
|
|
39
|
+
"model_selection",
|
|
40
|
+
"metrics",
|
|
41
|
+
]
|