ezyml 2__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.
- ezyml/__init__.py +9 -0
- ezyml/cli.py +102 -0
- ezyml/compiler/__init__.py +1 -0
- ezyml/compiler/compile.py +137 -0
- ezyml/core.py +1005 -0
- ezyml/deploy/__init__.py +5 -0
- ezyml/deploy/docker.py +21 -0
- ezyml/deploy/fastapi.py +30 -0
- ezyml/deploy/k8s.py +125 -0
- ezyml/deploy/openapi.py +19 -0
- ezyml/deploy/streamlit.py +205 -0
- ezyml/devx/__init___.py +1 -0
- ezyml/devx/doctor.py +7 -0
- ezyml/devx/init.py +6 -0
- ezyml/eda/__init__.py +0 -0
- ezyml/eda/auto_eda.py +22 -0
- ezyml/evaluation/__init__.py +0 -0
- ezyml/evaluation/evaluator.py +43 -0
- ezyml/evaluation/metrics.py +25 -0
- ezyml/evaluation/plots.py +23 -0
- ezyml/explain/__init__.py +0 -0
- ezyml/explain/learner.py +12 -0
- ezyml/monitoring/__init__.py +0 -0
- ezyml/monitoring/drift.py +9 -0
- ezyml/monitoring/fingerprint.py +8 -0
- ezyml/pipeline/__init__.py +0 -0
- ezyml/pipeline/loader.py +84 -0
- ezyml/pipeline/visualize.py +9 -0
- ezyml/training/__init__.py +0 -0
- ezyml/training/tuner.py +6 -0
- ezyml-2.dist-info/METADATA +341 -0
- ezyml-2.dist-info/RECORD +36 -0
- ezyml-2.dist-info/WHEEL +5 -0
- ezyml-2.dist-info/entry_points.txt +2 -0
- ezyml-2.dist-info/licenses/LICENSE +21 -0
- ezyml-2.dist-info/top_level.txt +1 -0
ezyml/__init__.py
ADDED
ezyml/cli.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# ezyml/cli.py
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
from ezyml.core import EZTrainer
|
|
7
|
+
from ezyml.compiler.compile import compile_project
|
|
8
|
+
from ezyml.eda.auto_eda import auto_eda
|
|
9
|
+
from ezyml.monitoring.fingerprint import dataset_fingerprint
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def compile_cli(args):
|
|
13
|
+
print("\n--- EZYML :: COMPILE ---")
|
|
14
|
+
|
|
15
|
+
df = pd.read_csv(args.data)
|
|
16
|
+
|
|
17
|
+
if not args.no_eda:
|
|
18
|
+
auto_eda(df, target=args.target)
|
|
19
|
+
print("[EDA] Completed")
|
|
20
|
+
|
|
21
|
+
# --------------------------------------------------
|
|
22
|
+
# PIPELINE (OPTIONAL) OR FALLBACK TRAINER
|
|
23
|
+
# --------------------------------------------------
|
|
24
|
+
if args.pipeline:
|
|
25
|
+
try:
|
|
26
|
+
from ezyml.pipeline.loader import load_pipeline
|
|
27
|
+
except ImportError:
|
|
28
|
+
raise RuntimeError(
|
|
29
|
+
"Pipeline support is not available in this installation.\n"
|
|
30
|
+
"Either install ezyml with pipeline support or run without --pipeline."
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
pipeline = load_pipeline(args.pipeline)
|
|
34
|
+
trainer = pipeline.run(df, target=args.target)
|
|
35
|
+
|
|
36
|
+
else:
|
|
37
|
+
print("[INFO] No pipeline provided. Using implicit EZTrainer.")
|
|
38
|
+
trainer = EZTrainer(
|
|
39
|
+
data=df,
|
|
40
|
+
target=args.target,
|
|
41
|
+
model=args.model,
|
|
42
|
+
task="classification"
|
|
43
|
+
)
|
|
44
|
+
trainer.train()
|
|
45
|
+
|
|
46
|
+
fingerprint = dataset_fingerprint(df)
|
|
47
|
+
print(f"[FINGERPRINT] {fingerprint}")
|
|
48
|
+
|
|
49
|
+
schema = {c: "number" for c in df.drop(columns=[args.target]).columns}
|
|
50
|
+
|
|
51
|
+
# --all overrides everything
|
|
52
|
+
api = args.api or args.all
|
|
53
|
+
demo = args.demo or args.all
|
|
54
|
+
docker = args.docker or args.all
|
|
55
|
+
k8s = args.k8s or args.all
|
|
56
|
+
|
|
57
|
+
compile_project(
|
|
58
|
+
trainer=trainer,
|
|
59
|
+
schema=schema,
|
|
60
|
+
api=api,
|
|
61
|
+
demo=demo,
|
|
62
|
+
docker=docker,
|
|
63
|
+
k8s=k8s
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
print("\n[SUCCESS] Compilation complete.")
|
|
67
|
+
print("Generated:")
|
|
68
|
+
print(" model.pkl")
|
|
69
|
+
print(" metrics.json")
|
|
70
|
+
if api: print(" app.py + openapi.json")
|
|
71
|
+
if demo: print(" demo_app.py")
|
|
72
|
+
if docker: print(" Dockerfile")
|
|
73
|
+
if k8s: print(" k8s.yaml")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def main():
|
|
77
|
+
parser = argparse.ArgumentParser("ezyml")
|
|
78
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
79
|
+
|
|
80
|
+
compile_cmd = sub.add_parser("compile")
|
|
81
|
+
compile_cmd.add_argument("--data", required=True)
|
|
82
|
+
compile_cmd.add_argument("--target", required=True)
|
|
83
|
+
|
|
84
|
+
# OPTIONAL
|
|
85
|
+
compile_cmd.add_argument("--pipeline", required=False)
|
|
86
|
+
compile_cmd.add_argument("--model", default="random_forest")
|
|
87
|
+
|
|
88
|
+
compile_cmd.add_argument("--api", action="store_true")
|
|
89
|
+
compile_cmd.add_argument("--demo", action="store_true")
|
|
90
|
+
compile_cmd.add_argument("--docker", action="store_true")
|
|
91
|
+
compile_cmd.add_argument("--k8s", action="store_true")
|
|
92
|
+
compile_cmd.add_argument("--all", action="store_true")
|
|
93
|
+
|
|
94
|
+
compile_cmd.add_argument("--no-eda", action="store_true")
|
|
95
|
+
compile_cmd.set_defaults(func=compile_cli)
|
|
96
|
+
|
|
97
|
+
args = parser.parse_args()
|
|
98
|
+
args.func(args)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# from pathlib import Path
|
|
2
|
+
# from ezyml.deploy import (
|
|
3
|
+
# generate_fastapi_app,
|
|
4
|
+
# generate_dockerfile,
|
|
5
|
+
# generate_openapi_spec,
|
|
6
|
+
# generate_streamlit_app,
|
|
7
|
+
# generate_k8s_manifests
|
|
8
|
+
# )
|
|
9
|
+
|
|
10
|
+
# def compile_project(
|
|
11
|
+
# model,
|
|
12
|
+
# pipeline,
|
|
13
|
+
# schema,
|
|
14
|
+
# image_name="ezyml-model",
|
|
15
|
+
# replicas=1,
|
|
16
|
+
# with_demo=True,
|
|
17
|
+
# with_k8s=True,
|
|
18
|
+
# build_dir="build"
|
|
19
|
+
# ):
|
|
20
|
+
# """
|
|
21
|
+
# One-command ML system compiler.
|
|
22
|
+
# """
|
|
23
|
+
|
|
24
|
+
# build_dir = Path(build_dir)
|
|
25
|
+
# build_dir.mkdir(exist_ok=True)
|
|
26
|
+
|
|
27
|
+
# # ---- Core artifacts ----
|
|
28
|
+
# model_path = build_dir / "model.pkl"
|
|
29
|
+
# pipeline_path = build_dir / "pipeline.pkl"
|
|
30
|
+
|
|
31
|
+
# import pickle
|
|
32
|
+
# pickle.dump(model, open(model_path, "wb"))
|
|
33
|
+
# pickle.dump(pipeline, open(pipeline_path, "wb"))
|
|
34
|
+
|
|
35
|
+
# # ---- API & Docs ----
|
|
36
|
+
# generate_fastapi_app(model_path, schema, output_path=build_dir / "app.py")
|
|
37
|
+
# generate_openapi_spec(schema, output_path=build_dir / "openapi.json")
|
|
38
|
+
|
|
39
|
+
# # ---- Demo ----
|
|
40
|
+
# if with_demo:
|
|
41
|
+
# generate_streamlit_app(model_path, schema, output_path=build_dir / "demo_app.py")
|
|
42
|
+
|
|
43
|
+
# # ---- Docker ----
|
|
44
|
+
# generate_dockerfile(output_path=build_dir / "Dockerfile")
|
|
45
|
+
|
|
46
|
+
# # ---- Kubernetes ----
|
|
47
|
+
# if with_k8s:
|
|
48
|
+
# generate_k8s_manifests(
|
|
49
|
+
# app_name=image_name,
|
|
50
|
+
# image=f"{image_name}:latest",
|
|
51
|
+
# replicas=replicas,
|
|
52
|
+
# output_prefix=build_dir / "k8s"
|
|
53
|
+
# )
|
|
54
|
+
|
|
55
|
+
# return {
|
|
56
|
+
# "model": model_path,
|
|
57
|
+
# "pipeline": pipeline_path,
|
|
58
|
+
# "api": build_dir / "app.py",
|
|
59
|
+
# "dockerfile": build_dir / "Dockerfile",
|
|
60
|
+
# "openapi": build_dir / "openapi.json",
|
|
61
|
+
# "k8s": build_dir / "k8s.yaml" if with_k8s else None
|
|
62
|
+
# }
|
|
63
|
+
# ezyml/compiler/compile.py
|
|
64
|
+
|
|
65
|
+
from pathlib import Path
|
|
66
|
+
import pickle
|
|
67
|
+
import json
|
|
68
|
+
|
|
69
|
+
from ezyml.deploy import (
|
|
70
|
+
generate_fastapi_app,
|
|
71
|
+
generate_dockerfile,
|
|
72
|
+
generate_openapi_spec,
|
|
73
|
+
generate_streamlit_app,
|
|
74
|
+
generate_k8s_manifests
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
def compile_project(
|
|
78
|
+
trainer,
|
|
79
|
+
schema,
|
|
80
|
+
build_dir="build",
|
|
81
|
+
api=False,
|
|
82
|
+
demo=False,
|
|
83
|
+
docker=False,
|
|
84
|
+
k8s=False,
|
|
85
|
+
plots=False
|
|
86
|
+
):
|
|
87
|
+
build_dir = Path(build_dir)
|
|
88
|
+
build_dir.mkdir(exist_ok=True)
|
|
89
|
+
|
|
90
|
+
# --------------------------------------------------
|
|
91
|
+
# ALWAYS GENERATED (MINIMUM CONTRACT)
|
|
92
|
+
# --------------------------------------------------
|
|
93
|
+
model_path = build_dir / "model.pkl"
|
|
94
|
+
metrics_path = build_dir / "metrics.json"
|
|
95
|
+
|
|
96
|
+
with open(model_path, "wb") as f:
|
|
97
|
+
pickle.dump(trainer.pipeline, f)
|
|
98
|
+
|
|
99
|
+
with open(metrics_path, "w") as f:
|
|
100
|
+
json.dump(trainer.report, f, indent=2)
|
|
101
|
+
|
|
102
|
+
# --------------------------------------------------
|
|
103
|
+
# OPTIONAL OUTPUTS
|
|
104
|
+
# --------------------------------------------------
|
|
105
|
+
if api:
|
|
106
|
+
generate_fastapi_app(
|
|
107
|
+
model_path=model_path,
|
|
108
|
+
schema=schema,
|
|
109
|
+
output_path=build_dir / "app.py"
|
|
110
|
+
)
|
|
111
|
+
generate_openapi_spec(schema, output_path=build_dir / "openapi.json")
|
|
112
|
+
|
|
113
|
+
if demo:
|
|
114
|
+
generate_streamlit_app(
|
|
115
|
+
model_path=model_path,
|
|
116
|
+
schema=schema,
|
|
117
|
+
output_path=build_dir / "demo_app.py"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
if docker:
|
|
121
|
+
generate_dockerfile(output_path=build_dir / "Dockerfile")
|
|
122
|
+
|
|
123
|
+
if k8s:
|
|
124
|
+
generate_k8s_manifests(
|
|
125
|
+
app_name="ezyml-model",
|
|
126
|
+
image="ezyml-model:latest",
|
|
127
|
+
output_prefix=build_dir / "k8s"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
"model": model_path,
|
|
132
|
+
"metrics": metrics_path,
|
|
133
|
+
"api": api,
|
|
134
|
+
"demo": demo,
|
|
135
|
+
"docker": docker,
|
|
136
|
+
"k8s": k8s
|
|
137
|
+
}
|