mlql 0.1.0__py3-none-any.whl

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/__init__.py 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")
mlql/core.py ADDED
@@ -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,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: mlql
3
+ Version: 0.1.0
4
+ Summary: Machine Learning Quality of Life Library
5
+ Requires-Dist: scikit-learn
6
+ Requires-Dist: matplotlib
7
+ Requires-Dist: seaborn
8
+ Requires-Dist: pandas
9
+ Requires-Dist: numpy
@@ -0,0 +1,6 @@
1
+ mlql/__init__.py,sha256=AdlaWMLM_OWURnt-J9zo0PdK5ytDHxITXpxF6skZOtU,1237
2
+ mlql/core.py,sha256=_RcImAUV2AFqDBPZ6fQh0zj1PPtIQwIbU77y7ymG8hc,3485
3
+ mlql-0.1.0.dist-info/METADATA,sha256=CPy3ky4cOgzUqWhi7jVzkyAbgHwwSs0MDU9Jle1SF1E,227
4
+ mlql-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ mlql-0.1.0.dist-info/top_level.txt,sha256=MQOdexZVmAkDHpfS8sW2HeB8qm6QD3wYYA1rLDi8Iro,5
6
+ mlql-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ mlql