Skip to content

Commit

Permalink
fix sklearn warnings (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
pplonski committed Mar 4, 2024
1 parent ad55e0f commit c95abfd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 0 additions & 5 deletions examples/scripts/multi_class_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
from supervised import AutoML
from supervised.exceptions import AutoMLException

# warnings.filterwarnings('error')
warnings.filterwarnings(
"error", category=pd.core.common.SettingWithCopyWarning
) # message="*ndarray*")

df = pd.read_csv("tests/data/iris_missing_values_missing_target.csv")
X = df[["feature_1", "feature_2", "feature_3", "feature_4"]]
y = df["class"]
Expand Down
11 changes: 10 additions & 1 deletion supervised/algorithms/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
MULTICLASS_CLASSIFICATION = "multiclass_classification"
REGRESSION = "regression"


class AlgorithmsRegistry:
registry = {
BINARY_CLASSIFICATION: {},
Expand Down Expand Up @@ -65,3 +64,13 @@ def get_eval_metric(algorithm_name, ml_task, automl_eval_metric):
return automl_eval_metric

# Import algorithm to be registered
import supervised.algorithms.baseline
import supervised.algorithms.catboost
import supervised.algorithms.decision_tree
import supervised.algorithms.extra_trees
import supervised.algorithms.knn
import supervised.algorithms.lightgbm
import supervised.algorithms.linear
import supervised.algorithms.nn
import supervised.algorithms.random_forest
import supervised.algorithms.xgboost
2 changes: 1 addition & 1 deletion supervised/utils/importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def log_loss_eps(y_true, y_pred):
return ll


log_loss_scorer = make_scorer(log_loss_eps, greater_is_better=False, needs_proba=True)
log_loss_scorer = make_scorer(log_loss_eps, greater_is_better=False, response_method="predict_proba")


class PermutationImportance:
Expand Down
6 changes: 2 additions & 4 deletions supervised/utils/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@


def logloss(y_true, y_predicted, sample_weight=None):
epsilon = 1e-6
y_predicted = sp.maximum(epsilon, y_predicted)
y_predicted = sp.minimum(1 - epsilon, y_predicted)
ll = log_loss(y_true, y_predicted, sample_weight=sample_weight)
# convert predicted values to float32 to avoid warnings
ll = log_loss(y_true, y_predicted.astype(np.float32), sample_weight=sample_weight)
return ll


Expand Down

0 comments on commit c95abfd

Please sign in to comment.