Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

113 roadmap get metrics through sdk and visualise them in jupyter notebook #141

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ APP_NAME_CRON=Whitebox | Development
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres

VERSION=0.1.0
METRICS_CRON=*/15 * * * *
METRICS_CRON=*/3 * * * *

MODEL_PATH=models
1 change: 1 addition & 0 deletions descriptive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id": "99d7c601-925b-4d58-96b3-8bca2bbdff19", "created_at": "2023-02-09T14:33:00.483453", "updated_at": "2023-02-09T14:33:00.483453", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-22T00:00:00", "feature_metrics": {"missing_count": {"sepal length (cm)": 0, "sepal width (cm)": 0, "petal length (cm)": 0, "petal width (cm)": 0, "target": 0}, "non_missing_count": {"sepal length (cm)": 10, "sepal width (cm)": 10, "petal length (cm)": 10, "petal width (cm)": 10, "target": 10}, "mean": {"sepal length (cm)": 5.679999999999999, "sepal width (cm)": 3.1, "petal length (cm)": 3.1799999999999997, "petal width (cm)": 0.97, "target": 0.7}, "minimum": {"sepal length (cm)": 4.8, "sepal width (cm)": 2.5, "petal length (cm)": 1.4, "petal width (cm)": 0.1, "target": 0.0}, "maximum": {"sepal length (cm)": 6.5, "sepal width (cm)": 3.9, "petal length (cm)": 5.6, "petal width (cm)": 2.1, "target": 2.0}, "sum": {"sepal length (cm)": 56.79999999999999, "sepal width (cm)": 31.0, "petal length (cm)": 31.799999999999997, "petal width (cm)": 9.7, "target": 7.0}, "standard_deviation": {"sepal length (cm)": 0.6779052703405954, "sepal width (cm)": 0.408248290463863, "petal length (cm)": 1.8262286579481526, "petal width (cm)": 0.7557924465236618, "target": 0.8232726023485646}, "variance": {"sepal length (cm)": 0.4595555555555558, "sepal width (cm)": 0.16666666666666666, "petal length (cm)": 3.335111111111111, "petal width (cm)": 0.5712222222222223, "target": 0.6777777777777778}}}, {"id": "4a7ca49b-ece6-45ac-a9cc-9560ab72cb73", "created_at": "2023-02-09T14:36:00.531345", "updated_at": "2023-02-09T14:36:00.531345", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-23T00:00:00", "feature_metrics": {"missing_count": {"sepal length (cm)": 0, "sepal width (cm)": 0, "petal length (cm)": 0, "petal width (cm)": 0, "target": 0}, "non_missing_count": {"sepal length (cm)": 20, "sepal width (cm)": 20, "petal length (cm)": 20, "petal width (cm)": 20, "target": 20}, "mean": {"sepal length (cm)": 5.819999999999999, "sepal width (cm)": 3.1050000000000004, "petal length (cm)": 3.560000000000001, "petal width (cm)": 1.1300000000000001, "target": 0.9}, "minimum": {"sepal length (cm)": 4.6, "sepal width (cm)": 2.5, "petal length (cm)": 1.4, "petal width (cm)": 0.1, "target": 0.0}, "maximum": {"sepal length (cm)": 7.2, "sepal width (cm)": 3.9, "petal length (cm)": 6.0, "petal width (cm)": 2.1, "target": 2.0}, "sum": {"sepal length (cm)": 116.39999999999999, "sepal width (cm)": 62.10000000000001, "petal length (cm)": 71.20000000000002, "petal width (cm)": 22.6, "target": 18.0}, "standard_deviation": {"sepal length (cm)": 0.7770389138802578, "sepal width (cm)": 0.3235900590497018, "petal length (cm)": 1.7922053453775881, "petal width (cm)": 0.7664683191173177, "target": 0.8522416262267904}, "variance": {"sepal length (cm)": 0.6037894736842108, "sepal width (cm)": 0.10471052631578948, "petal length (cm)": 3.2119999999999997, "petal width (cm)": 0.5874736842105264, "target": 0.7263157894736844}}}, {"id": "5a6f6f9f-98c7-4c7b-94ab-8fe6c60a3906", "created_at": "2023-02-09T14:39:00.626188", "updated_at": "2023-02-09T14:39:00.626188", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-24T00:00:00", "feature_metrics": {"missing_count": {"sepal length (cm)": 0, "sepal width (cm)": 0, "petal length (cm)": 0, "petal width (cm)": 0, "target": 0}, "non_missing_count": {"sepal length (cm)": 30, "sepal width (cm)": 30, "petal length (cm)": 30, "petal width (cm)": 30, "target": 30}, "mean": {"sepal length (cm)": 5.876666666666666, "sepal width (cm)": 3.2199999999999998, "petal length (cm)": 3.4433333333333334, "petal width (cm)": 1.0966666666666667, "target": 0.8333333333333334}, "minimum": {"sepal length (cm)": 4.6, "sepal width (cm)": 2.5, "petal length (cm)": 1.2, "petal width (cm)": 0.1, "target": 0.0}, "maximum": {"sepal length (cm)": 7.2, "sepal width (cm)": 4.0, "petal length (cm)": 6.1, "petal width (cm)": 2.5, "target": 2.0}, "sum": {"sepal length (cm)": 176.29999999999998, "sepal width (cm)": 96.6, "petal length (cm)": 103.3, "petal width (cm)": 32.9, "target": 25.0}, "standard_deviation": {"sepal length (cm)": 0.8041630188708883, "sepal width (cm)": 0.37268827688047546, "petal length (cm)": 1.8108263180169955, "petal width (cm)": 0.7967534699981061, "target": 0.8339078479367936}, "variance": {"sepal length (cm)": 0.6466781609195406, "sepal width (cm)": 0.13889655172413795, "petal length (cm)": 3.2790919540229884, "petal width (cm)": 0.634816091954023, "target": 0.6954022988505746}}}]
1 change: 1 addition & 0 deletions drift.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id": "b3381df8-56b4-43f6-aa72-523427b7d723", "created_at": "2023-02-09T14:33:00.456240", "updated_at": "2023-02-09T14:33:00.456240", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-22T00:00:00", "concept_drift_summary": {"concept_drift_summary": {"column_name": "target", "column_type": "cat", "stattest_name": "chi-square p_value", "drift_score": 0.3896307449384165, "drift_detected": false, "stattest_threshold": 0.05}, "column_correlation": {"column_name": "target", "current": {}, "reference": {}}}, "data_drift_summary": {"number_of_columns": 4, "number_of_drifted_columns": 0, "share_of_drifted_columns": 0.0, "dataset_drift": false, "drift_by_columns": {"petal length (cm)": {"column_name": "petal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.7588302830810655, "drift_detected": false, "threshold": 0.05}, "petal width (cm)": {"column_name": "petal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.7588302830810655, "drift_detected": false, "threshold": 0.05}, "sepal length (cm)": {"column_name": "sepal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.8382225197478262, "drift_detected": false, "threshold": 0.05}, "sepal width (cm)": {"column_name": "sepal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.9540265350498883, "drift_detected": false, "threshold": 0.05}}}},{"id": "6f74de30-9a5c-4a88-9e02-0a7d8777e242", "created_at": "2023-02-09T14:36:00.506190", "updated_at": "2023-02-09T14:36:00.506190", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-23T00:00:00", "concept_drift_summary": {"concept_drift_summary": {"column_name": "target", "column_type": "cat", "stattest_name": "chi-square p_value", "drift_score": 0.6738389777139696, "drift_detected": false, "stattest_threshold": 0.05}, "column_correlation": {"column_name": "target", "current": {}, "reference": {}}}, "data_drift_summary": {"number_of_columns": 4, "number_of_drifted_columns": 0, "share_of_drifted_columns": 0.0, "dataset_drift": false, "drift_by_columns": {"petal length (cm)": {"column_name": "petal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.9797880018857934, "drift_detected": false, "threshold": 0.05}, "petal width (cm)": {"column_name": "petal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.9325945507895383, "drift_detected": false, "threshold": 0.05}, "sepal length (cm)": {"column_name": "sepal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.8957682983065736, "drift_detected": false, "threshold": 0.05}, "sepal width (cm)": {"column_name": "sepal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.7450045755465691, "drift_detected": false, "threshold": 0.05}}}}, {"id": "78453a39-faa0-4aa7-bb30-8e4e1b91fef4", "created_at": "2023-02-09T14:39:00.608156", "updated_at": "2023-02-09T14:39:00.608156", "model_id": "83539c2b-579f-4a2c-b7ba-02d31c9408d8", "timestamp": "2022-12-24T00:00:00", "concept_drift_summary": {"concept_drift_summary": {"column_name": "target", "column_type": "cat", "stattest_name": "chi-square p_value", "drift_score": 0.32175216781613775, "drift_detected": false, "stattest_threshold": 0.05}, "column_correlation": {"column_name": "target", "current": {}, "reference": {}}}, "data_drift_summary": {"number_of_columns": 4, "number_of_drifted_columns": 0, "share_of_drifted_columns": 0.0, "dataset_drift": false, "drift_by_columns": {"petal length (cm)": {"column_name": "petal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.692577574430372, "drift_detected": false, "threshold": 0.05}, "petal width (cm)": {"column_name": "petal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.692577574430372, "drift_detected": false, "threshold": 0.05}, "sepal length (cm)": {"column_name": "sepal length (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.8799325977736985, "drift_detected": false, "threshold": 0.05}, "sepal width (cm)": {"column_name": "sepal width (cm)", "column_type": "num", "stattest_name": "K-S p_value", "drift_score": 0.1333377862549532, "drift_detected": false, "threshold": 0.05}}}}]
28 changes: 28 additions & 0 deletions examples/notebooks/plot_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pandas as pd
import seaborn as sns


def desriptive_statistics_plot(report, timestep):
df = pd.DataFrame.from_dict(report[timestep]["feature_metrics"])
df = df.drop(["target"])
df["class"] = df.index
df_pivot = pd.melt(df, id_vars="class", var_name="statistics", value_name="value")
gfg = sns.catplot(
x="statistics",
y="value",
hue="class",
data=df_pivot,
kind="bar",
orient="v",
aspect=7 / 3,
palette="Spectral",
)
sns.set_theme(style="whitegrid")
gfg.set(
xlabel="",
ylabel="",
title="Descriptive Statistics for "
+ report[timestep]["timestamp"].strip("T00:00:00"),
)

return gfg
Loading