mlql 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.
Potentially problematic release.
This version of mlql might be problematic. Click here for more details.
- mlql-0.1.0/PKG-INFO +9 -0
- mlql-0.1.0/README.md +52 -0
- mlql-0.1.0/pyproject.toml +15 -0
- mlql-0.1.0/setup.cfg +4 -0
- mlql-0.1.0/src/mlql/__init__.py +23 -0
- mlql-0.1.0/src/mlql/core.py +82 -0
- mlql-0.1.0/src/mlql.egg-info/PKG-INFO +9 -0
- mlql-0.1.0/src/mlql.egg-info/SOURCES.txt +9 -0
- mlql-0.1.0/src/mlql.egg-info/dependency_links.txt +1 -0
- mlql-0.1.0/src/mlql.egg-info/requires.txt +5 -0
- mlql-0.1.0/src/mlql.egg-info/top_level.txt +1 -0
mlql-0.1.0/PKG-INFO
ADDED
mlql-0.1.0/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# MLQL (Machine Learning Quality of Life Library)
|
|
2
|
+
|
|
3
|
+
**MLQL** is a zero-config Python library designed to eliminate the boilerplate code in data science and machine learning workflows.
|
|
4
|
+
|
|
5
|
+
Built on top of Scikit-learn, it abstracts away repetitive tasks like `train_test_split`, `fit`, and `predict`. With just one line of code, you can train a model, run diagnostic checks, and generate beautiful, presentation-ready visualizations.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **One-Line Analysis:** Just pass your features and target; MLQL handles the rest.
|
|
10
|
+
- **Automated Diagnostics:** The built-in engine warns you in the terminal if your model is overfitting, underfitting, or experiencing a data leak (overconfidence).
|
|
11
|
+
- **Automated Visualizations:** Generate dark-themed ROC curves, F1 heatmaps, and R² scatter plots with a single command.
|
|
12
|
+
- **Safe Defaults:** Instead of Scikit-learn's default parameters (like infinite depth trees), MLQL initializes 8 core algorithms with "safe hyperparameters" to prevent overfitting right out of the box.
|
|
13
|
+
|
|
14
|
+
## API Reference & Methods
|
|
15
|
+
|
|
16
|
+
MLQL automatically handles the `train_test_split`, `fit` processes, and diagnostic checks under the hood. Just call the visualization method you need!
|
|
17
|
+
|
|
18
|
+
### F1 & ROC Plots
|
|
19
|
+
|
|
20
|
+
**Logistic Regression**
|
|
21
|
+
- `mlql.lreg.show_roc(X, y)`
|
|
22
|
+
- `mlql.lreg.show_f1(X, y)`
|
|
23
|
+
|
|
24
|
+
**Random Forest Classifier**
|
|
25
|
+
- `mlql.rfc.show_roc(X, y)`
|
|
26
|
+
- `mlql.rfc.show_f1(X, y)`
|
|
27
|
+
|
|
28
|
+
**Support Vector Classifier (SVC)**
|
|
29
|
+
- `mlql.svc.show_roc(X, y)`
|
|
30
|
+
- `mlql.svc.show_f1(X, y)`
|
|
31
|
+
|
|
32
|
+
**K-Nearest Neighbors (KNN)**
|
|
33
|
+
- `mlql.knn.show_roc(X, y)`
|
|
34
|
+
- `mlql.knn.show_f1(X, y)`
|
|
35
|
+
|
|
36
|
+
**Gradient Boosting Classifier**
|
|
37
|
+
- `mlql.gbc.show_roc(X, y)`
|
|
38
|
+
- `mlql.gbc.show_f1(X, y)`
|
|
39
|
+
|
|
40
|
+
**Decision Tree Classifier**
|
|
41
|
+
- `mlql.dtree.show_roc(X, y)`
|
|
42
|
+
- `mlql.dtree.show_f1(X, y)`
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### R² Plots
|
|
47
|
+
|
|
48
|
+
**Linear Regression**
|
|
49
|
+
- `mlql.linreg.show_r2(X, y)`
|
|
50
|
+
|
|
51
|
+
**Random Forest Regressor**
|
|
52
|
+
- `mlql.rfr.show_r2(X, y)`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mlql"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Machine Learning Quality of Life Library"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"scikit-learn",
|
|
11
|
+
"matplotlib",
|
|
12
|
+
"seaborn",
|
|
13
|
+
"pandas",
|
|
14
|
+
"numpy"
|
|
15
|
+
]
|
mlql-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from sklearn.linear_model import LogisticRegression, LinearRegression
|
|
2
|
+
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor, GradientBoostingClassifier
|
|
3
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
4
|
+
from sklearn.svm import SVC
|
|
5
|
+
from sklearn.neighbors import KNeighborsClassifier
|
|
6
|
+
from .core import AutoModel
|
|
7
|
+
|
|
8
|
+
__version__ = "1.0.0"
|
|
9
|
+
|
|
10
|
+
lreg = AutoModel(LogisticRegression(max_iter=2000, class_weight='balanced'), task="clf")
|
|
11
|
+
rfc = AutoModel(RandomForestClassifier(max_depth=5, min_samples_split=5), task="clf")
|
|
12
|
+
svc = AutoModel(SVC(probability=True, kernel='rbf', C=1.0), task="clf")
|
|
13
|
+
knn = AutoModel(KNeighborsClassifier(n_neighbors=5, weights='uniform'), task="clf")
|
|
14
|
+
gbc = AutoModel(GradientBoostingClassifier(max_depth=3, n_estimators=100), task="clf")
|
|
15
|
+
dtree = AutoModel(DecisionTreeClassifier(max_depth=5, class_weight='balanced'), task="clf")
|
|
16
|
+
|
|
17
|
+
linreg = AutoModel(LinearRegression(), task="reg")
|
|
18
|
+
rfr = AutoModel(RandomForestRegressor(max_depth=5, min_samples_split=5), task="reg")
|
|
19
|
+
|
|
20
|
+
from sklearn.naive_bayes import MultinomialNB
|
|
21
|
+
from sklearn.calibration import CalibratedClassifierCV
|
|
22
|
+
|
|
23
|
+
spam_nb = AutoModel(CalibratedClassifierCV(estimator=MultinomialNB(), method='sigmoid', cv=5), task="clf")
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import seaborn as sns
|
|
3
|
+
from sklearn.model_selection import train_test_split
|
|
4
|
+
from sklearn.metrics import roc_curve, auc, classification_report, r2_score
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
class AutoModel:
|
|
8
|
+
def __init__(self, model, task="clf"):
|
|
9
|
+
self.model = model
|
|
10
|
+
self.task = task
|
|
11
|
+
|
|
12
|
+
def _auto_run(self, X, y):
|
|
13
|
+
"""Automated training and diagnostic engine hidden from the user"""
|
|
14
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
15
|
+
|
|
16
|
+
self.model.fit(X_train, y_train)
|
|
17
|
+
|
|
18
|
+
train_score = self.model.score(X_train, y_train)
|
|
19
|
+
test_score = self.model.score(X_test, y_test)
|
|
20
|
+
|
|
21
|
+
print("-" * 50)
|
|
22
|
+
print(f"[{self.model.__class__.__name__}] Analiz Raporu:")
|
|
23
|
+
print(f"Training Score: {train_score:.3f} | Testing Score: {test_score:.3f}")
|
|
24
|
+
|
|
25
|
+
gap = train_score - test_score
|
|
26
|
+
if train_score >= 0.99 and test_score >= 0.99:
|
|
27
|
+
print("OVERCONFIDENT: The scores are suspiciously high. There might be data leakage.")
|
|
28
|
+
elif gap > 0.15:
|
|
29
|
+
print("OVERFITTING: The model has memorized the data! Its failing the test.)")
|
|
30
|
+
elif train_score < 0.60 and test_score < 0.60:
|
|
31
|
+
print("UNDERFITTING: The model is failing to learn the pattern. Either the data or the model is too simple.")
|
|
32
|
+
else:
|
|
33
|
+
print("HEALTHY: Balanced learning; no over or underfitting.")
|
|
34
|
+
print("-" * 50)
|
|
35
|
+
|
|
36
|
+
return X_test, y_test
|
|
37
|
+
|
|
38
|
+
def show_roc(self, X, y):
|
|
39
|
+
if self.task != "clf":
|
|
40
|
+
raise ValueError("The ROC curve is exclusively for classification models.")
|
|
41
|
+
|
|
42
|
+
X_test, y_test = self._auto_run(X, y)
|
|
43
|
+
y_pred_proba = self.model.predict_proba(X_test)[:, 1]
|
|
44
|
+
|
|
45
|
+
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
|
|
46
|
+
|
|
47
|
+
plt.figure(figsize=(6, 5))
|
|
48
|
+
plt.plot(fpr, tpr, color='#00F0FF', lw=2, label=f'AUC = {auc(fpr, tpr):.3f}')
|
|
49
|
+
plt.plot([0, 1], [0, 1], color='gray', linestyle='--')
|
|
50
|
+
plt.title(f"{self.model.__class__.__name__} - ROC Analizi")
|
|
51
|
+
plt.legend(loc="lower right")
|
|
52
|
+
plt.grid(alpha=0.2)
|
|
53
|
+
plt.show()
|
|
54
|
+
|
|
55
|
+
def show_f1(self, X, y):
|
|
56
|
+
if self.task != "clf":
|
|
57
|
+
raise ValueError("The F1 score is only for classification models.")
|
|
58
|
+
|
|
59
|
+
X_test, y_test = self._auto_run(X, y)
|
|
60
|
+
y_pred = self.model.predict(X_test)
|
|
61
|
+
|
|
62
|
+
rapor = classification_report(y_test, y_pred, output_dict=True)
|
|
63
|
+
df_rapor = pd.DataFrame(rapor).iloc[:-1, :].T
|
|
64
|
+
|
|
65
|
+
plt.figure(figsize=(7, 4))
|
|
66
|
+
sns.heatmap(df_rapor, annot=True, cmap="Purples", fmt=".2f", vmin=0, vmax=1)
|
|
67
|
+
plt.title(f"{self.model.__class__.__name__} - Classification Report")
|
|
68
|
+
plt.show()
|
|
69
|
+
|
|
70
|
+
def show_r2(self, X, y):
|
|
71
|
+
if self.task != "reg":
|
|
72
|
+
raise ValueError("The R² plot is only for regression models.")
|
|
73
|
+
|
|
74
|
+
X_test, y_test = self._auto_run(X, y)
|
|
75
|
+
y_pred = self.model.predict(X_test)
|
|
76
|
+
|
|
77
|
+
plt.figure(figsize=(6, 5))
|
|
78
|
+
plt.scatter(y_test, y_pred, alpha=0.5, color='teal')
|
|
79
|
+
plt.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'r--')
|
|
80
|
+
plt.title(f"{self.model.__class__.__name__} - Actual vs. Predicted (R²: {r2_score(y_test, y_pred):.3f})")
|
|
81
|
+
plt.grid(alpha=0.2)
|
|
82
|
+
plt.show()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mlql
|