Skip to content

Commit

Permalink
Update plots.py formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rsvarma95 committed Jun 26, 2021
1 parent 4fe0ca1 commit bc5831d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sklearn_genetic/plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

logger = logging.getLogger(__name__) # noqa

# Check if seaborn is installed as an extra requirement
Expand Down Expand Up @@ -109,7 +110,9 @@ def noise(score):
score_len = len(score)
score_std = score.std()
noise_ratio = 1e7
noise = (np.random.random(score_len)*score_std/noise_ratio) - (score_std/2*noise_ratio)
noise = (np.random.random(score_len) * score_std / noise_ratio) - (
score_std / 2 * noise_ratio
)
return noise


Expand Down Expand Up @@ -137,7 +140,10 @@ def plot_parallel_coordinates(estimator, features: list = None):
if not isinstance(param_grid[feature], Categorical):
non_categorical_features.append(feature)
else:
logger.warning("`%s` is Categorical variable! It was dropped from the plot feature list", feature)
logger.warning(
"`%s` is Categorical variable! It was dropped from the plot feature list",
feature,
)
stats = df[non_categorical_features]
else:
non_categorical_variables = []
Expand All @@ -146,8 +152,10 @@ def plot_parallel_coordinates(estimator, features: list = None):
non_categorical_variables.append(variable)
non_categorical_variables.append("score")
stats = df[non_categorical_variables]

stats["score_quartile"] = pd.qcut(score + noise(score), 4, labels=[1,2,3,4])
g = pd.plotting.parallel_coordinates(stats, "score_quartile", color=("#8E8E8D", "#4ECDC4", "#C7F464", "#FF0000"))

stats["score_quartile"] = pd.qcut(score + noise(score), 4, labels=[1, 2, 3, 4])
g = pd.plotting.parallel_coordinates(
stats, "score_quartile", color=("#8E8E8D", "#4ECDC4", "#C7F464", "#FF0000")
)

return g

0 comments on commit bc5831d

Please sign in to comment.