From 8c5cdca59f339485eacc2c86d09ca771d3d0e59b Mon Sep 17 00:00:00 2001 From: Siddhant Sadangi Date: Thu, 28 Dec 2023 18:04:02 +0100 Subject: [PATCH] Handling `NeptuneUnsupportedType` error if expected metadata not found --- CHANGELOG.md | 8 +++++ pyproject.toml | 4 +-- src/neptune_sklearn/impl/__init__.py | 52 ++++++++++++++++------------ 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58e575d..b18e74f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [UNRELEASED] neptune-sklearn 2.2.0 + +### Fixes +- `create_*_summary()` now does not throw a `NeptuneUnsupportedType` error if expected metadata is not found + +### Changes +- Bumped minimum supported Python version to 3.8 + ## neptune-sklearn 2.1.0 ### Changes diff --git a/pyproject.toml b/pyproject.toml index f867e03..c8aebf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ style = "semver" pattern = "default-unprefixed" [tool.poetry.dependencies] -python = "^3.7" +python = "^3.8" # Python lack of functionalities from future versions importlib-metadata = { version = "*", python = "<3.8" } @@ -45,7 +45,7 @@ name = "neptune-sklearn" readme = "README.md" version = "0.0.0" classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Science/Research", diff --git a/src/neptune_sklearn/impl/__init__.py b/src/neptune_sklearn/impl/__init__.py index f0454a1..8154803 100644 --- a/src/neptune_sklearn/impl/__init__.py +++ b/src/neptune_sklearn/impl/__init__.py @@ -144,17 +144,20 @@ def create_regressor_summary(regressor, X_train, X_test, y_train, y_test, nrows= "scores": get_scores(regressor, X_test, y_test, y_pred=y_pred), } - if log_charts: - reg_summary["diagnostics_charts"] = { - "learning_curve": create_learning_curve_chart(regressor, X_train, y_train), - "feature_importance": create_feature_importance_chart(regressor, X_train, y_train), - "residuals": create_residuals_chart(regressor, X_train, X_test, y_train, y_test), - "prediction_error": create_prediction_error_chart(regressor, X_train, X_test, y_train, y_test), - "cooks_distance": create_cooks_distance_chart(regressor, X_train, y_train), - } - reg_summary["integration/about/neptune-sklearn"] = __version__ + if log_charts: + if learning_curve := create_learning_curve_chart(regressor, X_train, y_train): + reg_summary["diagnostics_charts/learning_curve"] = learning_curve + if feature_importance := create_feature_importance_chart(regressor, X_train, y_train): + reg_summary["diagnostics_charts/feature_importance"] = feature_importance + if residuals := create_residuals_chart(regressor, X_train, X_test, y_train, y_test): + reg_summary["diagnostics_charts/residuals"] = residuals + if prediction_error := create_prediction_error_chart(regressor, X_train, X_test, y_train, y_test): + reg_summary["diagnostics_charts/prediction_error"] = prediction_error + if cooks_distance := create_cooks_distance_chart(regressor, X_train, y_train): + reg_summary["diagnostics_charts/cooks_distance"] = cooks_distance + return reg_summary @@ -217,17 +220,20 @@ def create_classifier_summary(classifier, X_train, X_test, y_train, y_test, nrow "scores": get_scores(classifier, X_test, y_test, y_pred=y_pred), } - if log_charts: - cls_summary["diagnostics_charts"] = { - "classification_report": create_classification_report_chart(classifier, X_train, X_test, y_train, y_test), - "confusion_matrix": create_confusion_matrix_chart(classifier, X_train, X_test, y_train, y_test), - "ROC_AUC": create_roc_auc_chart(classifier, X_train, X_test, y_train, y_test), - "precision_recall": create_precision_recall_chart(classifier, X_test, y_test), - "class_prediction_error": create_class_prediction_error_chart(classifier, X_train, X_test, y_train, y_test), - } - cls_summary["integration/about/neptune-sklearn"] = __version__ + if log_charts: + if classification_report := create_classification_report_chart(classifier, X_train, X_test, y_train, y_test): + cls_summary["diagnostics_charts/classification_report"] = classification_report + if confusion_matrix := create_confusion_matrix_chart(classifier, X_train, X_test, y_train, y_test): + cls_summary["diagnostics_charts/confusion_matrix"] = confusion_matrix + if ROC_AUC := create_roc_auc_chart(classifier, X_train, X_test, y_train, y_test): + cls_summary["diagnostics_charts/ROC_AUC"] = ROC_AUC + if precision_recall := create_precision_recall_chart(classifier, X_test, y_test): + cls_summary["diagnostics_charts/precision_recall"] = precision_recall + if class_prediction_error := create_class_prediction_error_chart(classifier, X_train, X_test, y_train, y_test): + cls_summary["diagnostics_charts/class_prediction_error"] = class_prediction_error + return cls_summary @@ -272,13 +278,13 @@ def create_kmeans_summary(model, X, nrows=1000, **kwargs): kmeans_summary["all_params"] = stringify_unsupported(get_estimator_params(model)) kmeans_summary["pickled_model"] = get_pickled_model(model) kmeans_summary["cluster_labels"] = get_cluster_labels(model, X, nrows=nrows, **kwargs) - kmeans_summary["diagnostics_charts"] = { - "kelbow": create_kelbow_chart(model, X, **kwargs), - "silhouette": create_silhouette_chart(model, X, **kwargs), - } - kmeans_summary["integration/about/neptune-sklearn"] = __version__ + if kelbow := create_kelbow_chart(model, X, **kwargs): + kmeans_summary["diagnostics_charts/kelbow"] = kelbow + if silhouette := create_silhouette_chart(model, X, **kwargs): + kmeans_summary["diagnostics_charts/silhouette"] = silhouette + return kmeans_summary