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

Supressing NeptuneUnsupportedType warning if expected metadata not found #21

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed walrus operator, reverted bump to py3.8
SiddhantSadangi committed Jan 9, 2024
commit ea442c8770221c1ba76347edb6e7c98ff38fd787
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
## [UNRELEASED] neptune-sklearn 2.2.0

### Changes
- Bumped minimum supported Python version to 3.8 ([#21](https://github.com/neptune-ai/neptune-sklearn/pull/21))
## [UNRELEASED] neptune-sklearn 2.1.1

### Fixes
- `create_*_summary()` now does not throw a `NeptuneUnsupportedType` error if expected metadata is not found ([#21](https://github.com/neptune-ai/neptune-sklearn/pull/21))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ style = "semver"
pattern = "default-unprefixed"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.7"

# Python lack of functionalities from future versions
importlib-metadata = { version = "*", python = "<3.8" }
43 changes: 29 additions & 14 deletions src/neptune_sklearn/impl/__init__.py
Original file line number Diff line number Diff line change
@@ -110,8 +110,8 @@ def create_regressor_summary(regressor, X_train, X_test, y_train, y_test, nrows=
log_charts (`bool`, optional): Whether to calculate and log chart visualizations.
Note: Calculating visualizations is potentially expensive depending on input data and regressor,
and may take some time to finish. This is equivalent to calling the following functions from
this module: `create_learning_curve_chart()`, `create_feature_importance_chart()`, `create_residuals_chart()`,
`create_prediction_error_chart()`, and `create_cooks_distance_chart()`.
this module: `create_learning_curve_chart()`, `create_feature_importance_chart()`,
`create_residuals_chart()`, `create_prediction_error_chart()`, and `create_cooks_distance_chart()`.

Returns:
`dict` with all summary items.
@@ -147,15 +147,21 @@ def create_regressor_summary(regressor, X_train, X_test, y_train, y_test, nrows=
reg_summary["integration/about/neptune-sklearn"] = __version__

if log_charts:
if learning_curve := create_learning_curve_chart(regressor, X_train, y_train):
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)

if learning_curve:
reg_summary["diagnostics_charts/learning_curve"] = learning_curve
if feature_importance := create_feature_importance_chart(regressor, X_train, y_train):
if feature_importance:
reg_summary["diagnostics_charts/feature_importance"] = feature_importance
if residuals := create_residuals_chart(regressor, X_train, X_test, y_train, y_test):
if residuals:
reg_summary["diagnostics_charts/residuals"] = residuals
if prediction_error := create_prediction_error_chart(regressor, X_train, X_test, y_train, y_test):
if prediction_error:
reg_summary["diagnostics_charts/prediction_error"] = prediction_error
if cooks_distance := create_cooks_distance_chart(regressor, X_train, y_train):
if cooks_distance:
reg_summary["diagnostics_charts/cooks_distance"] = cooks_distance

return reg_summary
@@ -223,15 +229,21 @@ def create_classifier_summary(classifier, X_train, X_test, y_train, y_test, nrow
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):
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)

if classification_report:
cls_summary["diagnostics_charts/classification_report"] = classification_report
if confusion_matrix := create_confusion_matrix_chart(classifier, X_train, X_test, y_train, y_test):
if confusion_matrix:
cls_summary["diagnostics_charts/confusion_matrix"] = confusion_matrix
if ROC_AUC := create_roc_auc_chart(classifier, X_train, X_test, y_train, y_test):
if ROC_AUC:
cls_summary["diagnostics_charts/ROC_AUC"] = ROC_AUC
if precision_recall := create_precision_recall_chart(classifier, X_test, y_test):
if precision_recall:
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):
if class_prediction_error:
cls_summary["diagnostics_charts/class_prediction_error"] = class_prediction_error

return cls_summary
@@ -280,9 +292,12 @@ def create_kmeans_summary(model, X, nrows=1000, **kwargs):
kmeans_summary["cluster_labels"] = get_cluster_labels(model, X, nrows=nrows, **kwargs)
kmeans_summary["integration/about/neptune-sklearn"] = __version__

if kelbow := create_kelbow_chart(model, X, **kwargs):
kelbow = create_kelbow_chart(model, X, **kwargs)
silhouette = create_silhouette_chart(model, X, **kwargs)

if kelbow:
kmeans_summary["diagnostics_charts/kelbow"] = kelbow
if silhouette := create_silhouette_chart(model, X, **kwargs):
if silhouette:
kmeans_summary["diagnostics_charts/silhouette"] = silhouette

return kmeans_summary