Skip to content

Commit

Permalink
Removed walrus operator, reverted bump to py3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddhantSadangi committed Jan 9, 2024
1 parent 22ae23e commit ea442c8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
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))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
43 changes: 29 additions & 14 deletions src/neptune_sklearn/impl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea442c8

Please sign in to comment.