mljunior 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.
- mljunior/__init__.py +1 -0
- mljunior/cli.py +256 -0
- mljunior/data.py +125 -0
- mljunior/modeling.py +155 -0
- mljunior/preprocessing.py +210 -0
- mljunior/report.py +129 -0
- mljunior-0.1.0.dist-info/METADATA +107 -0
- mljunior-0.1.0.dist-info/RECORD +12 -0
- mljunior-0.1.0.dist-info/WHEEL +5 -0
- mljunior-0.1.0.dist-info/entry_points.txt +2 -0
- mljunior-0.1.0.dist-info/licenses/LICENSE +201 -0
- mljunior-0.1.0.dist-info/top_level.txt +1 -0
mljunior/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
mljunior/cli.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
ML JUNIOR — an agent that does the hyperparameter-tuning grind for you.
|
|
4
|
+
|
|
5
|
+
Reads a dataset, cleans it, figures out the problem type, suggests
|
|
6
|
+
preprocessing, trains and tunes several algorithms, evaluates the winner on
|
|
7
|
+
a genuine held-out test set, saves the best model, and writes an experiment
|
|
8
|
+
report. Run `mljunior --demo` to see it end to end.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
import joblib
|
|
16
|
+
import pandas as pd
|
|
17
|
+
from sklearn.base import clone
|
|
18
|
+
from sklearn.model_selection import train_test_split
|
|
19
|
+
|
|
20
|
+
from mljunior.data import load_data, load_demo_data, profile_dataset, print_profile
|
|
21
|
+
from mljunior.preprocessing import (
|
|
22
|
+
detect_task_type, clean_dataset, suggest_preprocessing,
|
|
23
|
+
build_pipeline_preprocessor, encode_target,
|
|
24
|
+
)
|
|
25
|
+
from mljunior.modeling import (
|
|
26
|
+
get_model_catalog, quick_screen, tune_model, scoring_metric, evaluate_on_holdout,
|
|
27
|
+
)
|
|
28
|
+
from mljunior.report import generate_report
|
|
29
|
+
|
|
30
|
+
BANNER = r"""
|
|
31
|
+
__ __ _ _ _ _ _ _ ___ ___ ____
|
|
32
|
+
| \/ | | | | | | | \ | |_ _/ _ \| _ \
|
|
33
|
+
| |\/| | | | | | | | \| || | | | | |_) |
|
|
34
|
+
| | | | |___ | | |_| | |\ || | |_| | _ <
|
|
35
|
+
|_| |_|_____| |_|\___/|_| \_|___\___/|_| \_\
|
|
36
|
+
|
|
37
|
+
your ML training + tuning agent
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
MIN_ROWS_FOR_HOLDOUT = 20
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def step(n, title):
|
|
44
|
+
print(f"\n[Step {n}] {title}")
|
|
45
|
+
print("-" * 50)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main():
|
|
49
|
+
print(BANNER)
|
|
50
|
+
parser = argparse.ArgumentParser(description="ML JUNIOR: clean data, tune models, save the best one, write a report.")
|
|
51
|
+
parser.add_argument("--data", type=str, help="Path to dataset (csv, xlsx, json, or parquet)")
|
|
52
|
+
parser.add_argument("--target", type=str, help="Target/label column name")
|
|
53
|
+
parser.add_argument("--demo", action="store_true", help="Run on a built-in demo dataset")
|
|
54
|
+
parser.add_argument("--out-dir", type=str, default="mljunior_output", help="Output directory for model + report")
|
|
55
|
+
parser.add_argument("--quick", action="store_true", help="Faster run: fewer CV folds and tuning iterations")
|
|
56
|
+
args = parser.parse_args()
|
|
57
|
+
|
|
58
|
+
# --- Step 1: Read the dataset ---
|
|
59
|
+
step(1, "Reading the dataset")
|
|
60
|
+
if args.demo:
|
|
61
|
+
df, target = load_demo_data()
|
|
62
|
+
print("Using built-in demo dataset (breast cancer classification)")
|
|
63
|
+
elif args.data and args.target:
|
|
64
|
+
df = load_data(args.data)
|
|
65
|
+
target = args.target
|
|
66
|
+
elif args.data and not args.target:
|
|
67
|
+
df = load_data(args.data)
|
|
68
|
+
print(f"Columns found: {list(df.columns)}")
|
|
69
|
+
target = input("Which column should I predict? ").strip()
|
|
70
|
+
else:
|
|
71
|
+
print("No dataset given.")
|
|
72
|
+
path = input("Dataset path (or Enter for demo): ").strip()
|
|
73
|
+
if not path:
|
|
74
|
+
df, target = load_demo_data()
|
|
75
|
+
else:
|
|
76
|
+
df = load_data(path)
|
|
77
|
+
print(f"Columns found: {list(df.columns)}")
|
|
78
|
+
target = input("Which column should I predict? ").strip()
|
|
79
|
+
|
|
80
|
+
if target not in df.columns:
|
|
81
|
+
print(f"Error: target column '{target}' not found. Available: {list(df.columns)}")
|
|
82
|
+
sys.exit(1)
|
|
83
|
+
|
|
84
|
+
profile = profile_dataset(df, target)
|
|
85
|
+
print_profile(profile)
|
|
86
|
+
|
|
87
|
+
# --- Step 2: Identify classification/regression ---
|
|
88
|
+
step(2, "Identifying the problem type")
|
|
89
|
+
task_type = detect_task_type(df[target])
|
|
90
|
+
print(f"Detected: {task_type}")
|
|
91
|
+
|
|
92
|
+
# --- Step 3: Clean the data, then suggest + apply preprocessing ---
|
|
93
|
+
step(3, "Cleaning the dataset")
|
|
94
|
+
df, cleanup_notes = clean_dataset(df, target)
|
|
95
|
+
if cleanup_notes:
|
|
96
|
+
for note in cleanup_notes:
|
|
97
|
+
print(f" - {note}")
|
|
98
|
+
else:
|
|
99
|
+
print(" - Dataset was already clean, nothing to do")
|
|
100
|
+
|
|
101
|
+
y_raw = df[target]
|
|
102
|
+
X = df.drop(columns=[target])
|
|
103
|
+
|
|
104
|
+
print("\nPreprocessing plan:")
|
|
105
|
+
suggestions = suggest_preprocessing(X, y_raw, task_type)
|
|
106
|
+
for s in suggestions:
|
|
107
|
+
print(f" - {s}")
|
|
108
|
+
if not suggestions:
|
|
109
|
+
print(" - No special preprocessing needed")
|
|
110
|
+
|
|
111
|
+
preprocessor, id_cols = build_pipeline_preprocessor(X)
|
|
112
|
+
if id_cols:
|
|
113
|
+
X = X.drop(columns=id_cols)
|
|
114
|
+
y, label_encoder = encode_target(y_raw, task_type)
|
|
115
|
+
|
|
116
|
+
imbalanced = False
|
|
117
|
+
if task_type == "classification":
|
|
118
|
+
counts = y_raw.value_counts(normalize=True)
|
|
119
|
+
imbalanced = (counts.max() / max(counts.min(), 1e-9)) > 3
|
|
120
|
+
|
|
121
|
+
# --- Held-out split: tuning never sees this data ---
|
|
122
|
+
skip_holdout = len(X) < MIN_ROWS_FOR_HOLDOUT
|
|
123
|
+
if task_type == "classification" and not skip_holdout:
|
|
124
|
+
class_counts = pd.Series(y).value_counts()
|
|
125
|
+
if class_counts.min() < 2:
|
|
126
|
+
skip_holdout = True
|
|
127
|
+
|
|
128
|
+
if skip_holdout:
|
|
129
|
+
print(f"\n(Dataset too small for a reliable held-out test set — reporting "
|
|
130
|
+
f"cross-validated scores instead of true holdout performance)")
|
|
131
|
+
X_train, y_train = X, y
|
|
132
|
+
X_test, y_test = None, None
|
|
133
|
+
else:
|
|
134
|
+
try:
|
|
135
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
136
|
+
X, y, test_size=0.2, random_state=42,
|
|
137
|
+
stratify=y if task_type == "classification" else None,
|
|
138
|
+
)
|
|
139
|
+
except ValueError:
|
|
140
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
141
|
+
|
|
142
|
+
# --- Step 4-5: Train multiple models, quick cross-val screen (on train only) ---
|
|
143
|
+
step(4, "Training candidate models (quick cross-validated screen)")
|
|
144
|
+
cv_folds = 3
|
|
145
|
+
catalog = get_model_catalog(task_type, class_weight_balanced=imbalanced)
|
|
146
|
+
screen_scores = quick_screen(preprocessor, catalog, X_train, y_train, task_type, cv=cv_folds, imbalanced=imbalanced)
|
|
147
|
+
metric_name = scoring_metric(task_type, imbalanced)
|
|
148
|
+
if imbalanced:
|
|
149
|
+
print(f" (using {metric_name} instead of accuracy since classes are imbalanced)")
|
|
150
|
+
for name, score in sorted(screen_scores.items(), key=lambda kv: (kv[1] is None, -(kv[1] or 0))):
|
|
151
|
+
print(f" {name:<22} {metric_name}={score}")
|
|
152
|
+
|
|
153
|
+
ranked = sorted(
|
|
154
|
+
[(n, s) for n, s in screen_scores.items() if s is not None],
|
|
155
|
+
key=lambda kv: -kv[1],
|
|
156
|
+
)
|
|
157
|
+
if not ranked:
|
|
158
|
+
print("\nError: every candidate model failed during cross-validation.")
|
|
159
|
+
print("This usually means the dataset is too small or too imbalanced for the "
|
|
160
|
+
"requested number of CV folds (e.g. fewer than 2 samples in some class).")
|
|
161
|
+
print("Try a larger dataset, or a target column with more examples per class.")
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
n_iter = 4 if args.quick else 8
|
|
165
|
+
shortlist = [name for name, _ in ranked[: 4 if not args.quick else 2]]
|
|
166
|
+
|
|
167
|
+
# --- Step 5: Hyperparameter tuning (on train only) ---
|
|
168
|
+
step(5, f"Tuning hyperparameters for top {len(shortlist)} models")
|
|
169
|
+
tuned_results = []
|
|
170
|
+
fitted_pipelines = {}
|
|
171
|
+
for name in shortlist:
|
|
172
|
+
estimator, param_dist = catalog[name]
|
|
173
|
+
print(f" Tuning {name}...")
|
|
174
|
+
pipe, best_params, cv_score, std = tune_model(
|
|
175
|
+
preprocessor, estimator, param_dist, X_train, y_train, task_type,
|
|
176
|
+
n_iter=n_iter, cv=cv_folds, imbalanced=imbalanced,
|
|
177
|
+
)
|
|
178
|
+
row = {"name": name, "cv_score": cv_score, "std": std, "params": best_params}
|
|
179
|
+
|
|
180
|
+
if not skip_holdout:
|
|
181
|
+
holdout_metrics = evaluate_on_holdout(pipe, X_test, y_test, task_type)
|
|
182
|
+
primary_key = "F1" if (task_type == "classification" and imbalanced) else (
|
|
183
|
+
"Accuracy" if task_type == "classification" else "R2"
|
|
184
|
+
)
|
|
185
|
+
row["holdout_metrics"] = holdout_metrics
|
|
186
|
+
row["rank_score"] = holdout_metrics[primary_key]
|
|
187
|
+
else:
|
|
188
|
+
row["holdout_metrics"] = None
|
|
189
|
+
row["rank_score"] = cv_score
|
|
190
|
+
|
|
191
|
+
tuned_results.append(row)
|
|
192
|
+
fitted_pipelines[name] = pipe
|
|
193
|
+
|
|
194
|
+
tuned_results.sort(key=lambda r: -r["rank_score"])
|
|
195
|
+
|
|
196
|
+
# --- Step 6: Compare metrics ---
|
|
197
|
+
step(6, "Final leaderboard")
|
|
198
|
+
if skip_holdout:
|
|
199
|
+
print(f"{'Rank':<5}{'Model':<22}{'CV ' + metric_name:<16}")
|
|
200
|
+
for i, row in enumerate(tuned_results, 1):
|
|
201
|
+
print(f"{i:<5}{row['name']:<22}{row['cv_score']:<16}")
|
|
202
|
+
else:
|
|
203
|
+
print("(Scores below are on a held-out test set the models never trained or tuned on)")
|
|
204
|
+
header_metrics = list(tuned_results[0]["holdout_metrics"].keys())
|
|
205
|
+
print(f"{'Rank':<5}{'Model':<22}" + "".join(f"{m:<12}" for m in header_metrics) + f"{'CV ' + metric_name:<14}")
|
|
206
|
+
for i, row in enumerate(tuned_results, 1):
|
|
207
|
+
metric_str = "".join(f"{row['holdout_metrics'][m]:<12}" for m in header_metrics)
|
|
208
|
+
print(f"{i:<5}{row['name']:<22}{metric_str}{row['cv_score']:<14}")
|
|
209
|
+
|
|
210
|
+
best = tuned_results[0]
|
|
211
|
+
best_name = best["name"]
|
|
212
|
+
best_pipeline = fitted_pipelines[best_name]
|
|
213
|
+
print(f"\nBest model: {best_name} ({'holdout' if not skip_holdout else 'CV'} {metric_name}={best['rank_score']})")
|
|
214
|
+
|
|
215
|
+
# --- Step 7: Save best model (refit on ALL data for the production artifact) ---
|
|
216
|
+
step(7, "Saving the best model")
|
|
217
|
+
final_pipeline = clone(best_pipeline)
|
|
218
|
+
final_pipeline.fit(X, y) # refit on train+test combined, now that we've honestly measured generalization
|
|
219
|
+
|
|
220
|
+
os.makedirs(args.out_dir, exist_ok=True)
|
|
221
|
+
model_path = os.path.join(args.out_dir, "best_model.joblib")
|
|
222
|
+
joblib.dump({
|
|
223
|
+
"pipeline": final_pipeline,
|
|
224
|
+
"label_encoder": label_encoder,
|
|
225
|
+
"target": target,
|
|
226
|
+
"task_type": task_type,
|
|
227
|
+
"feature_columns": list(X.columns),
|
|
228
|
+
"dropped_id_columns": id_cols,
|
|
229
|
+
}, model_path)
|
|
230
|
+
print(f"Saved to: {model_path}")
|
|
231
|
+
print("(Refit on the full cleaned dataset for production use, after honestly measuring "
|
|
232
|
+
"generalization on the held-out split above)")
|
|
233
|
+
|
|
234
|
+
# --- Step 8: Generate experiment report ---
|
|
235
|
+
step(8, "Writing experiment report")
|
|
236
|
+
report_path = os.path.join(args.out_dir, "experiment_report.md")
|
|
237
|
+
generate_report(
|
|
238
|
+
profile=profile,
|
|
239
|
+
cleanup_notes=cleanup_notes,
|
|
240
|
+
task_type=task_type,
|
|
241
|
+
suggestions=suggestions,
|
|
242
|
+
screen_scores=screen_scores,
|
|
243
|
+
tuned_results=tuned_results,
|
|
244
|
+
skip_holdout=skip_holdout,
|
|
245
|
+
best_name=best_name,
|
|
246
|
+
best_params=best["params"],
|
|
247
|
+
model_path=model_path,
|
|
248
|
+
out_path=report_path,
|
|
249
|
+
)
|
|
250
|
+
print(f"Saved to: {report_path}")
|
|
251
|
+
|
|
252
|
+
print("\nDone. ML JUNIOR finished its shift.")
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
if __name__ == "__main__":
|
|
256
|
+
main()
|
mljunior/data.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Step 1-2: Load the dataset and profile it (shape, dtypes, missingness, balance)."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _sniff_real_format(path: str):
|
|
10
|
+
"""Look at the actual file bytes rather than trusting the extension —
|
|
11
|
+
it's common for a CSV/text export to be named .xlsx by mistake, or for
|
|
12
|
+
an old .xls (binary OLE format) to be involved."""
|
|
13
|
+
try:
|
|
14
|
+
with open(path, "rb") as f:
|
|
15
|
+
head = f.read(8)
|
|
16
|
+
except Exception:
|
|
17
|
+
return None
|
|
18
|
+
if head.startswith(b"PK\x03\x04"):
|
|
19
|
+
return "xlsx" # modern Excel = a zip file
|
|
20
|
+
if head.startswith(b"\xd0\xcf\x11\xe0"):
|
|
21
|
+
return "xls" # legacy Excel = OLE2 binary format
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def load_data(path: str) -> pd.DataFrame:
|
|
26
|
+
"""Load CSV, Excel, JSON, or Parquet. Tries multiple encodings for CSV
|
|
27
|
+
since real-world files (especially Excel exports) are often not UTF-8.
|
|
28
|
+
Verifies the real file format by content, not just the extension, since
|
|
29
|
+
mislabeled files (e.g. a CSV saved with a .xlsx extension) are common."""
|
|
30
|
+
if not os.path.exists(path):
|
|
31
|
+
print(f"Error: file not found: {path}")
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
ext = os.path.splitext(path)[1].lower()
|
|
35
|
+
sniffed = _sniff_real_format(path)
|
|
36
|
+
|
|
37
|
+
if ext == ".json":
|
|
38
|
+
return pd.read_json(path)
|
|
39
|
+
if ext == ".parquet":
|
|
40
|
+
return pd.read_parquet(path)
|
|
41
|
+
|
|
42
|
+
looks_like_excel = ext in (".xlsx", ".xls") or sniffed is not None
|
|
43
|
+
if looks_like_excel:
|
|
44
|
+
engine = "openpyxl" if sniffed == "xlsx" or (sniffed is None and ext == ".xlsx") else "xlrd"
|
|
45
|
+
try:
|
|
46
|
+
return pd.read_excel(path, engine=engine)
|
|
47
|
+
except Exception as e:
|
|
48
|
+
if ext in (".xlsx", ".xls") and sniffed is None:
|
|
49
|
+
print(f"Note: '{path}' has an Excel extension but isn't actually Excel "
|
|
50
|
+
f"format — reading it as text instead.")
|
|
51
|
+
# fall through to the CSV/text path below
|
|
52
|
+
else:
|
|
53
|
+
print(f"Error: could not read '{path}' as an Excel file ({e}).")
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
# CSV / TSV / anything else: try encodings, sniff delimiter
|
|
57
|
+
last_error = None
|
|
58
|
+
for encoding in ["utf-8", "utf-8-sig", "cp1252", "latin1"]:
|
|
59
|
+
try:
|
|
60
|
+
return pd.read_csv(path, encoding=encoding, sep=None, engine="python")
|
|
61
|
+
except UnicodeDecodeError as e:
|
|
62
|
+
last_error = e
|
|
63
|
+
continue
|
|
64
|
+
except Exception:
|
|
65
|
+
try:
|
|
66
|
+
return pd.read_csv(path, encoding=encoding)
|
|
67
|
+
except UnicodeDecodeError as e:
|
|
68
|
+
last_error = e
|
|
69
|
+
continue
|
|
70
|
+
|
|
71
|
+
print(f"Error: could not read '{path}' with any common encoding ({last_error}).")
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def load_demo_data():
|
|
76
|
+
from sklearn.datasets import load_breast_cancer
|
|
77
|
+
df = load_breast_cancer(as_frame=True).frame
|
|
78
|
+
return df, "target"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def profile_dataset(df: pd.DataFrame, target: str) -> dict:
|
|
82
|
+
"""Build a summary dict describing the dataset — used both for console
|
|
83
|
+
output and for the experiment report."""
|
|
84
|
+
n_rows, n_cols = df.shape
|
|
85
|
+
missing = df.isna().sum()
|
|
86
|
+
missing_pct = (missing / n_rows * 100).round(1)
|
|
87
|
+
missing_cols = {
|
|
88
|
+
col: f"{missing[col]} missing ({missing_pct[col]}%)"
|
|
89
|
+
for col in df.columns
|
|
90
|
+
if missing[col] > 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
y = df[target]
|
|
94
|
+
dtypes = df.drop(columns=[target]).dtypes.astype(str).to_dict()
|
|
95
|
+
|
|
96
|
+
class_balance = None
|
|
97
|
+
if not pd.api.types.is_numeric_dtype(y) or y.nunique() <= max(10, int(0.05 * n_rows)):
|
|
98
|
+
counts = y.value_counts(normalize=True).round(3) * 100
|
|
99
|
+
class_balance = counts.to_dict()
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
"n_rows": n_rows,
|
|
103
|
+
"n_cols": n_cols,
|
|
104
|
+
"target": target,
|
|
105
|
+
"dtypes": dtypes,
|
|
106
|
+
"missing_cols": missing_cols,
|
|
107
|
+
"class_balance": class_balance,
|
|
108
|
+
"duplicate_rows": int(df.duplicated().sum()),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def print_profile(profile: dict):
|
|
113
|
+
print(f"Rows: {profile['n_rows']} Columns: {profile['n_cols']} Target: {profile['target']}")
|
|
114
|
+
if profile["duplicate_rows"]:
|
|
115
|
+
print(f" Note: {profile['duplicate_rows']} duplicate rows found")
|
|
116
|
+
if profile["missing_cols"]:
|
|
117
|
+
print(" Missing values found in:")
|
|
118
|
+
for col, desc in profile["missing_cols"].items():
|
|
119
|
+
print(f" - {col}: {desc}")
|
|
120
|
+
else:
|
|
121
|
+
print(" No missing values detected")
|
|
122
|
+
if profile["class_balance"]:
|
|
123
|
+
print(" Class balance:")
|
|
124
|
+
for cls, pct in profile["class_balance"].items():
|
|
125
|
+
print(f" - {cls}: {pct}%")
|
mljunior/modeling.py
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""Step 4-6: Train multiple models with cross-validation, then tune
|
|
2
|
+
hyperparameters on the top performers."""
|
|
3
|
+
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
from sklearn.ensemble import (
|
|
8
|
+
GradientBoostingClassifier, GradientBoostingRegressor,
|
|
9
|
+
RandomForestClassifier, RandomForestRegressor,
|
|
10
|
+
)
|
|
11
|
+
from sklearn.linear_model import LogisticRegression, LinearRegression
|
|
12
|
+
from sklearn.metrics import (
|
|
13
|
+
accuracy_score, f1_score, precision_score, recall_score,
|
|
14
|
+
r2_score, mean_absolute_error, mean_squared_error,
|
|
15
|
+
)
|
|
16
|
+
from sklearn.model_selection import cross_val_score, RandomizedSearchCV
|
|
17
|
+
from sklearn.naive_bayes import GaussianNB
|
|
18
|
+
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
|
|
19
|
+
from sklearn.pipeline import Pipeline
|
|
20
|
+
from sklearn.svm import SVC, SVR
|
|
21
|
+
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
|
|
22
|
+
|
|
23
|
+
warnings.filterwarnings("ignore")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_model_catalog(task_type: str, class_weight_balanced: bool = False):
|
|
27
|
+
"""Returns {name: (estimator, param_distributions)} for RandomizedSearchCV."""
|
|
28
|
+
cw = "balanced" if class_weight_balanced else None
|
|
29
|
+
|
|
30
|
+
if task_type == "classification":
|
|
31
|
+
return {
|
|
32
|
+
"Logistic Regression": (
|
|
33
|
+
LogisticRegression(max_iter=2000, class_weight=cw),
|
|
34
|
+
{"model__C": [0.01, 0.1, 1, 10, 100]},
|
|
35
|
+
),
|
|
36
|
+
"Decision Tree": (
|
|
37
|
+
DecisionTreeClassifier(random_state=42, class_weight=cw),
|
|
38
|
+
{"model__max_depth": [3, 5, 10, None], "model__min_samples_leaf": [1, 2, 5]},
|
|
39
|
+
),
|
|
40
|
+
"Random Forest": (
|
|
41
|
+
RandomForestClassifier(random_state=42, class_weight=cw),
|
|
42
|
+
{"model__n_estimators": [100, 200, 400], "model__max_depth": [None, 10, 20],
|
|
43
|
+
"model__min_samples_leaf": [1, 2, 4]},
|
|
44
|
+
),
|
|
45
|
+
"Gradient Boosting": (
|
|
46
|
+
GradientBoostingClassifier(random_state=42),
|
|
47
|
+
{"model__n_estimators": [100, 200], "model__learning_rate": [0.01, 0.1, 0.2],
|
|
48
|
+
"model__max_depth": [2, 3, 4]},
|
|
49
|
+
),
|
|
50
|
+
"SVM": (
|
|
51
|
+
SVC(probability=True, random_state=42, class_weight=cw),
|
|
52
|
+
{"model__C": [0.1, 1, 10], "model__kernel": ["rbf", "linear"]},
|
|
53
|
+
),
|
|
54
|
+
"K-Nearest Neighbors": (
|
|
55
|
+
KNeighborsClassifier(),
|
|
56
|
+
{"model__n_neighbors": [3, 5, 7, 9, 15]},
|
|
57
|
+
),
|
|
58
|
+
"Naive Bayes": (
|
|
59
|
+
GaussianNB(),
|
|
60
|
+
{},
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
else:
|
|
64
|
+
return {
|
|
65
|
+
"Linear Regression": (LinearRegression(), {}),
|
|
66
|
+
"Decision Tree": (
|
|
67
|
+
DecisionTreeRegressor(random_state=42),
|
|
68
|
+
{"model__max_depth": [3, 5, 10, None], "model__min_samples_leaf": [1, 2, 5]},
|
|
69
|
+
),
|
|
70
|
+
"Random Forest": (
|
|
71
|
+
RandomForestRegressor(random_state=42),
|
|
72
|
+
{"model__n_estimators": [100, 200, 400], "model__max_depth": [None, 10, 20]},
|
|
73
|
+
),
|
|
74
|
+
"Gradient Boosting": (
|
|
75
|
+
GradientBoostingRegressor(random_state=42),
|
|
76
|
+
{"model__n_estimators": [100, 200], "model__learning_rate": [0.01, 0.1, 0.2],
|
|
77
|
+
"model__max_depth": [2, 3, 4]},
|
|
78
|
+
),
|
|
79
|
+
"SVR": (
|
|
80
|
+
SVR(),
|
|
81
|
+
{"model__C": [0.1, 1, 10], "model__kernel": ["rbf", "linear"]},
|
|
82
|
+
),
|
|
83
|
+
"K-Nearest Neighbors": (
|
|
84
|
+
KNeighborsRegressor(),
|
|
85
|
+
{"model__n_neighbors": [3, 5, 7, 9, 15]},
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def scoring_metric(task_type: str, imbalanced: bool = False) -> str:
|
|
91
|
+
if task_type == "classification":
|
|
92
|
+
return "f1_weighted" if imbalanced else "accuracy"
|
|
93
|
+
return "r2"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def quick_screen(preprocessor, catalog, X, y, task_type, cv=3, imbalanced=False):
|
|
97
|
+
"""Step 4-5: quick cross-val score for every model with default params,
|
|
98
|
+
to shortlist which ones deserve full hyperparameter tuning."""
|
|
99
|
+
scoring = scoring_metric(task_type, imbalanced)
|
|
100
|
+
scores = {}
|
|
101
|
+
for name, (estimator, _) in catalog.items():
|
|
102
|
+
pipe = Pipeline([("prep", preprocessor), ("model", estimator)])
|
|
103
|
+
try:
|
|
104
|
+
cv_scores = cross_val_score(pipe, X, y, cv=cv, scoring=scoring, n_jobs=-1)
|
|
105
|
+
scores[name] = round(float(np.mean(cv_scores)), 4)
|
|
106
|
+
except Exception:
|
|
107
|
+
scores[name] = None
|
|
108
|
+
return scores
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def tune_model(preprocessor, estimator, param_dist, X, y, task_type, n_iter=8, cv=3, imbalanced=False):
|
|
112
|
+
"""Step 6: hyperparameter tuning via RandomizedSearchCV for one model."""
|
|
113
|
+
scoring = scoring_metric(task_type, imbalanced)
|
|
114
|
+
pipe = Pipeline([("prep", preprocessor), ("model", estimator)])
|
|
115
|
+
|
|
116
|
+
if not param_dist:
|
|
117
|
+
# No hyperparameters to tune (e.g. Naive Bayes, Linear Regression) —
|
|
118
|
+
# just cross-validate for a stable score, then fit on all data.
|
|
119
|
+
cv_scores = cross_val_score(pipe, X, y, cv=cv, scoring=scoring, n_jobs=-1)
|
|
120
|
+
pipe.fit(X, y)
|
|
121
|
+
return pipe, {}, round(float(np.mean(cv_scores)), 4), round(float(np.std(cv_scores)), 4)
|
|
122
|
+
|
|
123
|
+
search = RandomizedSearchCV(
|
|
124
|
+
pipe, param_distributions=param_dist, n_iter=min(n_iter, _grid_size(param_dist)),
|
|
125
|
+
cv=cv, scoring=scoring, random_state=42, n_jobs=-1,
|
|
126
|
+
)
|
|
127
|
+
search.fit(X, y)
|
|
128
|
+
return search.best_estimator_, search.best_params_, round(search.best_score_, 4), None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _grid_size(param_dist: dict) -> int:
|
|
132
|
+
size = 1
|
|
133
|
+
for v in param_dist.values():
|
|
134
|
+
size *= len(v)
|
|
135
|
+
return size
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def evaluate_on_holdout(pipeline, X_test, y_test, task_type: str) -> dict:
|
|
139
|
+
"""The honest number: how the tuned pipeline performs on data it never
|
|
140
|
+
saw during training OR hyperparameter search. This — not the CV score
|
|
141
|
+
from the search — is what should be reported as the model's accuracy."""
|
|
142
|
+
preds = pipeline.predict(X_test)
|
|
143
|
+
if task_type == "classification":
|
|
144
|
+
return {
|
|
145
|
+
"Accuracy": round(accuracy_score(y_test, preds), 4),
|
|
146
|
+
"F1": round(f1_score(y_test, preds, average="weighted", zero_division=0), 4),
|
|
147
|
+
"Precision": round(precision_score(y_test, preds, average="weighted", zero_division=0), 4),
|
|
148
|
+
"Recall": round(recall_score(y_test, preds, average="weighted", zero_division=0), 4),
|
|
149
|
+
}
|
|
150
|
+
else:
|
|
151
|
+
return {
|
|
152
|
+
"R2": round(r2_score(y_test, preds), 4),
|
|
153
|
+
"MAE": round(mean_absolute_error(y_test, preds), 4),
|
|
154
|
+
"RMSE": round(float(np.sqrt(mean_squared_error(y_test, preds))), 4),
|
|
155
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Step 3: Look at the data, suggest a preprocessing plan in plain English,
|
|
2
|
+
and build the actual sklearn ColumnTransformer pipeline that implements it."""
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from sklearn.base import BaseEstimator, TransformerMixin
|
|
7
|
+
from sklearn.compose import ColumnTransformer
|
|
8
|
+
from sklearn.impute import SimpleImputer
|
|
9
|
+
from sklearn.pipeline import Pipeline
|
|
10
|
+
from sklearn.preprocessing import OneHotEncoder, StandardScaler, LabelEncoder
|
|
11
|
+
|
|
12
|
+
MAX_MISSING_FRACTION = 0.6 # drop a column if more than this fraction is missing
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FrequencyEncoder(BaseEstimator, TransformerMixin):
|
|
16
|
+
"""Encodes a categorical column as how common each value is (its
|
|
17
|
+
frequency in the training data), instead of an arbitrary integer label.
|
|
18
|
+
|
|
19
|
+
Why not LabelEncoder: assigning 0/1/2/3 to e.g. Chicago/Boston/NYC/LA
|
|
20
|
+
invents a false ranking that linear models, SVMs, and KNN all interpret
|
|
21
|
+
literally. Frequency encoding carries real signal (rare vs. common
|
|
22
|
+
category) without inventing an order.
|
|
23
|
+
|
|
24
|
+
Because this is a proper sklearn transformer, it only learns frequencies
|
|
25
|
+
from whatever data it's fit on — inside cross-validation that means only
|
|
26
|
+
the training fold, never the held-out fold. Unseen categories at
|
|
27
|
+
transform time get frequency 0.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def fit(self, X, y=None):
|
|
31
|
+
X = self._as_frame(X)
|
|
32
|
+
self.columns_ = list(X.columns)
|
|
33
|
+
self.freq_maps_ = {
|
|
34
|
+
col: X[col].astype(str).value_counts(normalize=True) for col in X.columns
|
|
35
|
+
}
|
|
36
|
+
return self
|
|
37
|
+
|
|
38
|
+
def transform(self, X):
|
|
39
|
+
X = self._as_frame(X)
|
|
40
|
+
out = np.zeros((len(X), len(self.columns_)))
|
|
41
|
+
for i, col in enumerate(self.columns_):
|
|
42
|
+
out[:, i] = X[col].astype(str).map(self.freq_maps_[col]).fillna(0.0).values
|
|
43
|
+
return out
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _as_frame(X):
|
|
47
|
+
return X if isinstance(X, pd.DataFrame) else pd.DataFrame(X)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _looks_like_id_column(col: pd.Series) -> bool:
|
|
51
|
+
"""True ID columns are either non-numeric all-unique values (names, UUIDs,
|
|
52
|
+
emails) or a numeric sequential index (0,1,2,...). A continuous numeric
|
|
53
|
+
feature like income or price can also be all-unique by chance — that's
|
|
54
|
+
normal, predictive data, not an ID, so it must NOT be dropped."""
|
|
55
|
+
if col.nunique(dropna=True) != len(col):
|
|
56
|
+
return False
|
|
57
|
+
if not pd.api.types.is_numeric_dtype(col):
|
|
58
|
+
return True
|
|
59
|
+
sorted_vals = col.sort_values().reset_index(drop=True)
|
|
60
|
+
diffs = sorted_vals.diff().dropna()
|
|
61
|
+
return bool((diffs == 1).all())
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def detect_task_type(y: pd.Series) -> str:
|
|
65
|
+
if not pd.api.types.is_numeric_dtype(y):
|
|
66
|
+
return "classification"
|
|
67
|
+
n_unique = y.nunique()
|
|
68
|
+
if n_unique <= max(10, int(0.05 * len(y))):
|
|
69
|
+
return "classification"
|
|
70
|
+
return "regression"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def clean_dataset(df: pd.DataFrame, target: str) -> tuple:
|
|
74
|
+
"""Actually cleans the data (not just reports on it). Returns
|
|
75
|
+
(cleaned_df, cleanup_notes: list[str])."""
|
|
76
|
+
notes = []
|
|
77
|
+
df = df.copy()
|
|
78
|
+
|
|
79
|
+
n_before = len(df)
|
|
80
|
+
missing_target = df[target].isna().sum()
|
|
81
|
+
if missing_target:
|
|
82
|
+
df = df[df[target].notna()]
|
|
83
|
+
notes.append(f"Dropped {missing_target} row(s) with a missing target value")
|
|
84
|
+
|
|
85
|
+
dupes = df.duplicated().sum()
|
|
86
|
+
if dupes:
|
|
87
|
+
df = df.drop_duplicates()
|
|
88
|
+
notes.append(f"Dropped {dupes} duplicate row(s)")
|
|
89
|
+
|
|
90
|
+
# Replace +/-inf (common after division-by-zero upstream) with NaN so the
|
|
91
|
+
# imputer handles them like any other missing value.
|
|
92
|
+
num_cols = df.select_dtypes(include="number").columns
|
|
93
|
+
inf_count = np.isinf(df[num_cols]).sum().sum() if len(num_cols) else 0
|
|
94
|
+
if inf_count:
|
|
95
|
+
df[num_cols] = df[num_cols].replace([np.inf, -np.inf], np.nan)
|
|
96
|
+
notes.append(f"Replaced {inf_count} infinite value(s) with missing (to be imputed)")
|
|
97
|
+
|
|
98
|
+
X_cols = [c for c in df.columns if c != target]
|
|
99
|
+
missing_frac = df[X_cols].isna().mean()
|
|
100
|
+
high_missing = missing_frac[missing_frac > MAX_MISSING_FRACTION].index.tolist()
|
|
101
|
+
if high_missing:
|
|
102
|
+
df = df.drop(columns=high_missing)
|
|
103
|
+
notes.append(
|
|
104
|
+
f"Dropped {len(high_missing)} column(s) that are >{int(MAX_MISSING_FRACTION*100)}% "
|
|
105
|
+
f"missing (too sparse to impute meaningfully): {high_missing}"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
X_cols = [c for c in df.columns if c != target]
|
|
109
|
+
constant_cols = [c for c in X_cols if df[c].nunique(dropna=True) <= 1]
|
|
110
|
+
if constant_cols:
|
|
111
|
+
df = df.drop(columns=constant_cols)
|
|
112
|
+
notes.append(f"Dropped {len(constant_cols)} constant column(s) with no variation: {constant_cols}")
|
|
113
|
+
|
|
114
|
+
if len(df) < n_before:
|
|
115
|
+
notes.append(f"Rows: {n_before} -> {len(df)} after cleaning")
|
|
116
|
+
|
|
117
|
+
return df, notes
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def suggest_preprocessing(X: pd.DataFrame, y: pd.Series, task_type: str) -> list:
|
|
121
|
+
"""Returns a list of human-readable suggestion strings, and is also used
|
|
122
|
+
to decide what the pipeline actually does."""
|
|
123
|
+
suggestions = []
|
|
124
|
+
|
|
125
|
+
num_cols = X.select_dtypes(include="number").columns.tolist()
|
|
126
|
+
cat_cols = X.select_dtypes(exclude="number").columns.tolist()
|
|
127
|
+
|
|
128
|
+
missing = X.isna().sum()
|
|
129
|
+
if missing.any():
|
|
130
|
+
suggestions.append(
|
|
131
|
+
f"Impute remaining missing values (median for numeric, most-frequent for categorical) "
|
|
132
|
+
f"in {(missing > 0).sum()} column(s)"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if cat_cols:
|
|
136
|
+
high_card = [c for c in cat_cols if X[c].nunique() > 20]
|
|
137
|
+
low_card = [c for c in cat_cols if X[c].nunique() <= 20]
|
|
138
|
+
if low_card:
|
|
139
|
+
suggestions.append(f"One-hot encode {len(low_card)} low-cardinality categorical column(s): {low_card}")
|
|
140
|
+
if high_card:
|
|
141
|
+
suggestions.append(
|
|
142
|
+
f"Frequency-encode {len(high_card)} high-cardinality column(s) (too many unique "
|
|
143
|
+
f"values for one-hot; frequency encoding avoids inventing a false ranking "
|
|
144
|
+
f"the way label-encoding would): {high_card}"
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
if num_cols:
|
|
148
|
+
suggestions.append(f"Standard-scale {len(num_cols)} numeric column(s) (zero mean, unit variance)")
|
|
149
|
+
|
|
150
|
+
if task_type == "classification":
|
|
151
|
+
counts = y.value_counts(normalize=True)
|
|
152
|
+
if counts.max() / max(counts.min(), 1e-9) > 3:
|
|
153
|
+
suggestions.append(
|
|
154
|
+
f"Class imbalance detected (largest class is {counts.max()*100:.0f}% of data) — "
|
|
155
|
+
f"using class_weight='balanced' where supported"
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
dropped = [c for c in X.columns if _looks_like_id_column(X[c])]
|
|
159
|
+
if dropped:
|
|
160
|
+
suggestions.append(
|
|
161
|
+
f"Drop {len(dropped)} likely ID column(s) with all-unique values (no predictive signal): {dropped}"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
return suggestions
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def build_pipeline_preprocessor(X: pd.DataFrame):
|
|
168
|
+
"""Builds the actual ColumnTransformer used inside every model's Pipeline.
|
|
169
|
+
Everything here — imputation, encoding, scaling — lives inside the
|
|
170
|
+
pipeline, so it's refit fresh on every CV fold's training data only."""
|
|
171
|
+
id_cols = [c for c in X.columns if _looks_like_id_column(X[c])]
|
|
172
|
+
usable_cols = [c for c in X.columns if c not in id_cols]
|
|
173
|
+
|
|
174
|
+
num_cols = X[usable_cols].select_dtypes(include="number").columns.tolist()
|
|
175
|
+
cat_cols_all = X[usable_cols].select_dtypes(exclude="number").columns.tolist()
|
|
176
|
+
low_card = [c for c in cat_cols_all if X[c].nunique() <= 20]
|
|
177
|
+
high_card = [c for c in cat_cols_all if X[c].nunique() > 20]
|
|
178
|
+
|
|
179
|
+
transformers = []
|
|
180
|
+
|
|
181
|
+
if num_cols:
|
|
182
|
+
num_pipeline = Pipeline([
|
|
183
|
+
("impute", SimpleImputer(strategy="median")),
|
|
184
|
+
("scale", StandardScaler()),
|
|
185
|
+
])
|
|
186
|
+
transformers.append(("num", num_pipeline, num_cols))
|
|
187
|
+
|
|
188
|
+
if low_card:
|
|
189
|
+
cat_pipeline = Pipeline([
|
|
190
|
+
("impute", SimpleImputer(strategy="most_frequent")),
|
|
191
|
+
("encode", OneHotEncoder(handle_unknown="ignore")),
|
|
192
|
+
])
|
|
193
|
+
transformers.append(("cat_low", cat_pipeline, low_card))
|
|
194
|
+
|
|
195
|
+
if high_card:
|
|
196
|
+
high_card_pipeline = Pipeline([
|
|
197
|
+
("impute", SimpleImputer(strategy="most_frequent")),
|
|
198
|
+
("freq_encode", FrequencyEncoder()),
|
|
199
|
+
])
|
|
200
|
+
transformers.append(("cat_high", high_card_pipeline, high_card))
|
|
201
|
+
|
|
202
|
+
preprocessor = ColumnTransformer(transformers, remainder="drop")
|
|
203
|
+
return preprocessor, id_cols
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def encode_target(y: pd.Series, task_type: str):
|
|
207
|
+
if task_type == "classification" and not pd.api.types.is_numeric_dtype(y):
|
|
208
|
+
le = LabelEncoder()
|
|
209
|
+
return le.fit_transform(y.astype(str)), le
|
|
210
|
+
return y, None
|
mljunior/report.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Step 8: Generate a markdown experiment report summarizing the whole run."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def generate_report(
|
|
7
|
+
profile: dict,
|
|
8
|
+
cleanup_notes: list,
|
|
9
|
+
task_type: str,
|
|
10
|
+
suggestions: list,
|
|
11
|
+
screen_scores: dict,
|
|
12
|
+
tuned_results: list,
|
|
13
|
+
skip_holdout: bool,
|
|
14
|
+
best_name: str,
|
|
15
|
+
best_params: dict,
|
|
16
|
+
model_path: str,
|
|
17
|
+
out_path: str,
|
|
18
|
+
):
|
|
19
|
+
lines = []
|
|
20
|
+
lines.append("# ML JUNIOR — experiment report")
|
|
21
|
+
lines.append(f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}")
|
|
22
|
+
lines.append("")
|
|
23
|
+
|
|
24
|
+
lines.append("## 1. Dataset")
|
|
25
|
+
lines.append(f"- Rows: {profile['n_rows']}")
|
|
26
|
+
lines.append(f"- Columns: {profile['n_cols']}")
|
|
27
|
+
lines.append(f"- Target: `{profile['target']}`")
|
|
28
|
+
lines.append(f"- Task type: **{task_type}**")
|
|
29
|
+
if profile["duplicate_rows"]:
|
|
30
|
+
lines.append(f"- Duplicate rows found: {profile['duplicate_rows']}")
|
|
31
|
+
if profile["missing_cols"]:
|
|
32
|
+
lines.append("- Missing values found:")
|
|
33
|
+
for col, desc in profile["missing_cols"].items():
|
|
34
|
+
lines.append(f" - `{col}`: {desc}")
|
|
35
|
+
else:
|
|
36
|
+
lines.append("- Missing values: none detected")
|
|
37
|
+
if profile["class_balance"]:
|
|
38
|
+
lines.append("- Class balance:")
|
|
39
|
+
for cls, pct in profile["class_balance"].items():
|
|
40
|
+
lines.append(f" - `{cls}`: {pct}%")
|
|
41
|
+
lines.append("")
|
|
42
|
+
|
|
43
|
+
lines.append("## 2. Cleaning applied")
|
|
44
|
+
if cleanup_notes:
|
|
45
|
+
for note in cleanup_notes:
|
|
46
|
+
lines.append(f"- {note}")
|
|
47
|
+
else:
|
|
48
|
+
lines.append("- Dataset was already clean, nothing to do")
|
|
49
|
+
lines.append("")
|
|
50
|
+
|
|
51
|
+
lines.append("## 3. Preprocessing plan")
|
|
52
|
+
for s in suggestions:
|
|
53
|
+
lines.append(f"- {s}")
|
|
54
|
+
if not suggestions:
|
|
55
|
+
lines.append("- No special preprocessing needed")
|
|
56
|
+
lines.append("")
|
|
57
|
+
|
|
58
|
+
lines.append("## 4. Quick screen (default hyperparameters, cross-validated on training data only)")
|
|
59
|
+
lines.append("| Model | Score |")
|
|
60
|
+
lines.append("|---|---|")
|
|
61
|
+
for name, score in sorted(screen_scores.items(), key=lambda kv: (kv[1] is None, -(kv[1] or 0))):
|
|
62
|
+
lines.append(f"| {name} | {score if score is not None else 'failed'} |")
|
|
63
|
+
lines.append("")
|
|
64
|
+
|
|
65
|
+
lines.append("## 5. Final leaderboard")
|
|
66
|
+
if skip_holdout:
|
|
67
|
+
lines.append(
|
|
68
|
+
"_Dataset was too small for a reliable held-out test set, so these are "
|
|
69
|
+
"cross-validated scores rather than true holdout performance._"
|
|
70
|
+
)
|
|
71
|
+
lines.append("")
|
|
72
|
+
lines.append("| Rank | Model | CV score | Best hyperparameters |")
|
|
73
|
+
lines.append("|---|---|---|---|")
|
|
74
|
+
for i, row in enumerate(tuned_results, 1):
|
|
75
|
+
params_str = ", ".join(f"{k.split('__')[-1]}={v}" for k, v in row["params"].items()) or "defaults"
|
|
76
|
+
lines.append(f"| {i} | {row['name']} | {row['cv_score']} | {params_str} |")
|
|
77
|
+
else:
|
|
78
|
+
lines.append(
|
|
79
|
+
"_These scores are measured on a held-out test set the models never saw during "
|
|
80
|
+
"training or hyperparameter tuning — this is the honest estimate of real-world performance._"
|
|
81
|
+
)
|
|
82
|
+
lines.append("")
|
|
83
|
+
metric_keys = list(tuned_results[0]["holdout_metrics"].keys())
|
|
84
|
+
header = "| Rank | Model | " + " | ".join(metric_keys) + " | CV score (search estimate) | Best hyperparameters |"
|
|
85
|
+
sep = "|---" * (len(metric_keys) + 4) + "|"
|
|
86
|
+
lines.append(header)
|
|
87
|
+
lines.append(sep)
|
|
88
|
+
for i, row in enumerate(tuned_results, 1):
|
|
89
|
+
metric_vals = " | ".join(str(row["holdout_metrics"][m]) for m in metric_keys)
|
|
90
|
+
params_str = ", ".join(f"{k.split('__')[-1]}={v}" for k, v in row["params"].items()) or "defaults"
|
|
91
|
+
lines.append(f"| {i} | {row['name']} | {metric_vals} | {row['cv_score']} | {params_str} |")
|
|
92
|
+
lines.append("")
|
|
93
|
+
|
|
94
|
+
lines.append("## 6. Best model")
|
|
95
|
+
lines.append(f"**{best_name}**")
|
|
96
|
+
if best_params:
|
|
97
|
+
lines.append("")
|
|
98
|
+
lines.append("Best hyperparameters:")
|
|
99
|
+
for k, v in best_params.items():
|
|
100
|
+
lines.append(f"- `{k.split('__')[-1]}`: {v}")
|
|
101
|
+
lines.append("")
|
|
102
|
+
lines.append(
|
|
103
|
+
f"The saved model was refit on the **full cleaned dataset** (train + held-out test "
|
|
104
|
+
f"combined) after the honest performance estimate above was measured — this maximizes "
|
|
105
|
+
f"real-world performance without affecting the reported metrics."
|
|
106
|
+
)
|
|
107
|
+
lines.append("")
|
|
108
|
+
lines.append(f"Saved to: `{model_path}`")
|
|
109
|
+
lines.append("")
|
|
110
|
+
|
|
111
|
+
lines.append("## 7. How to use the saved model")
|
|
112
|
+
lines.append("```python")
|
|
113
|
+
lines.append("import joblib")
|
|
114
|
+
lines.append("")
|
|
115
|
+
lines.append(f"saved = joblib.load('{model_path}')")
|
|
116
|
+
lines.append("pipeline = saved['pipeline']")
|
|
117
|
+
lines.append("label_encoder = saved['label_encoder'] # None for regression tasks")
|
|
118
|
+
lines.append("feature_columns = saved['feature_columns'] # columns the model expects, in order")
|
|
119
|
+
lines.append("")
|
|
120
|
+
lines.append("# new_data_df: pandas DataFrame with these same feature columns")
|
|
121
|
+
lines.append("# (drop any ID columns first — see saved['dropped_id_columns'])")
|
|
122
|
+
lines.append("predictions = pipeline.predict(new_data_df[feature_columns])")
|
|
123
|
+
lines.append("")
|
|
124
|
+
lines.append("if label_encoder is not None:")
|
|
125
|
+
lines.append(" predictions = label_encoder.inverse_transform(predictions) # back to original labels")
|
|
126
|
+
lines.append("```")
|
|
127
|
+
|
|
128
|
+
with open(out_path, "w") as f:
|
|
129
|
+
f.write("\n".join(lines))
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mljunior
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ML JUNIOR — automatically trains, tunes, evaluates, and saves machine learning models.
|
|
5
|
+
Author: Gopesh
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pandas>=2.0
|
|
11
|
+
Requires-Dist: numpy>=1.24
|
|
12
|
+
Requires-Dist: scikit-learn>=1.3
|
|
13
|
+
Requires-Dist: joblib>=1.3
|
|
14
|
+
Requires-Dist: openpyxl>=3.1
|
|
15
|
+
Requires-Dist: pyarrow>=14.0
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# ML JUNIOR
|
|
19
|
+
|
|
20
|
+
An agent that does the model-selection and hyperparameter-tuning grind for
|
|
21
|
+
you: point it at a dataset, and it reads it, figures out the problem type,
|
|
22
|
+
suggests and applies preprocessing, trains and tunes several algorithms,
|
|
23
|
+
saves the best one, and writes an experiment report — announcing every step
|
|
24
|
+
as it happens.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
__ __ _ _ _ _ _ _ ___ ___ ____
|
|
28
|
+
| \/ | | | | | | | \ | |_ _/ _ \| _ \
|
|
29
|
+
| |\/| | | | | | | | \| || | | | | |_) |
|
|
30
|
+
| | | | |___ | | |_| | |\ || | |_| | _ <
|
|
31
|
+
|_| |_|_____| |_|\___/|_| \_|___\___/|_| \_\
|
|
32
|
+
|
|
33
|
+
your ML training + tuning agent
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Install (one time)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
unzip mljunior.zip
|
|
40
|
+
cd ml-junior
|
|
41
|
+
pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`mljunior` is now a system command, usable from any folder — no `cd`-ing
|
|
45
|
+
back into this repo required.
|
|
46
|
+
|
|
47
|
+
## Use it
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mljunior --demo # try it on a built-in dataset
|
|
51
|
+
mljunior --data datasets/your_file.csv --target y # your own dataset
|
|
52
|
+
mljunior # no flags — it asks interactively
|
|
53
|
+
mljunior --data data.csv --target y --quick # faster: fewer CV folds/tuning iters
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Supports CSV, Excel (`.xlsx`), JSON, and Parquet. CSVs are read with automatic
|
|
57
|
+
encoding detection (handles Excel exports that aren't UTF-8).
|
|
58
|
+
|
|
59
|
+
## What it does — step by step
|
|
60
|
+
|
|
61
|
+
1. **Reads and cleans the dataset** — any of the formats above, profiles rows/columns/missingness/class balance
|
|
62
|
+
2. **Identifies the problem type** — classification or regression, from the target column
|
|
63
|
+
3. **Suggests + applies preprocessing** — imputation, one-hot/label encoding, scaling, class-imbalance handling — all explained in plain English before it's applied
|
|
64
|
+
4. **Trains multiple algorithms** — cross-validated quick screen with default hyperparameters
|
|
65
|
+
5. **Tunes hyperparameters** — `RandomizedSearchCV` on the top performers
|
|
66
|
+
6. **Compares metrics** — a final leaderboard (accuracy/F1 for classification — F1 automatically when classes are imbalanced; R2 for regression)
|
|
67
|
+
7. **Saves the best model** — `mljunior_output/best_model.joblib`, a full sklearn Pipeline (preprocessing + model together)
|
|
68
|
+
8. **Generates an experiment report** — `mljunior_output/experiment_report.md`, documenting every step above
|
|
69
|
+
|
|
70
|
+
##Seeing the features
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import joblib
|
|
74
|
+
|
|
75
|
+
saved = joblib.load("mljunior_output/best_model.joblib")
|
|
76
|
+
pipeline = saved["pipeline"]
|
|
77
|
+
|
|
78
|
+
print(list(pipeline.feature_names_in_))
|
|
79
|
+
```
|
|
80
|
+
## Using the saved model later
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import joblib
|
|
84
|
+
|
|
85
|
+
saved = joblib.load('mljunior_output/best_model.joblib')
|
|
86
|
+
pipeline = saved['pipeline']
|
|
87
|
+
label_encoder = saved['label_encoder'] # None for regression tasks
|
|
88
|
+
|
|
89
|
+
predictions = pipeline.predict(new_data_df) # same feature columns as training data
|
|
90
|
+
if label_encoder is not None:
|
|
91
|
+
predictions = label_encoder.inverse_transform(predictions) # back to original labels
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Adding your own dataset
|
|
95
|
+
|
|
96
|
+
Drop a CSV/Excel/JSON/Parquet file into the `datasets/` folder (or anywhere
|
|
97
|
+
else — it's just a suggested spot):
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
mljunior --data datasets/my_data.csv --target my_target_column
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Uninstall
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip uninstall mljunior
|
|
107
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
mljunior/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
|
|
2
|
+
mljunior/cli.py,sha256=-B3S0GDrKQQQXb7hIOTKmy4eNRYd7aGWb-HVa373SEw,10171
|
|
3
|
+
mljunior/data.py,sha256=7TmjOM4ZmeGfIkVOxNtU8EfOdnRArcGs53Gzf4XW0NE,4490
|
|
4
|
+
mljunior/modeling.py,sha256=Ps7lbs6zTWJId9vHQMb1r6YSyTp1meOX1T_B839XIVI,6482
|
|
5
|
+
mljunior/preprocessing.py,sha256=u5yEgBnoiRAYQ2_4xwyBpsdfhD5N_AytI7DBEfIZAJg,8400
|
|
6
|
+
mljunior/report.py,sha256=Nl74MSYWfSefIRNbvmz2bWaSlKGbVnYt2k-8keD4gQ0,5411
|
|
7
|
+
mljunior-0.1.0.dist-info/licenses/LICENSE,sha256=MhjDHHJ0uuHoqc3CIhuqhcpUyqZhAI7qtWo_Z_UF1MQ,11336
|
|
8
|
+
mljunior-0.1.0.dist-info/METADATA,sha256=dhns8yoKfidp6nfFpMlbnGPr8uxyjLuqeWzFQx0ReKI,3613
|
|
9
|
+
mljunior-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
10
|
+
mljunior-0.1.0.dist-info/entry_points.txt,sha256=rsDCOLmbVFizLYKtd906Rd5fY9n-X5TlU-ht8H76J7s,47
|
|
11
|
+
mljunior-0.1.0.dist-info/top_level.txt,sha256=tx87zG7tGbx5Z3pHhwAfm1PJzbpezTIkNJ6rXqSVm50,9
|
|
12
|
+
mljunior-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Gopesh
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mljunior
|