Skip to content

Commit 4b4209d

Browse files
Merge pull request #2852 from plotly/xhlulu-patch-ml-error
Fix error in "Multiclass ROC Curve"
2 parents 24763dc + ce87fcd commit 4b4209d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/python/ml-roc-pr.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.4.2
8+
format_version: '1.1'
9+
jupytext_version: 1.1.1
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -142,13 +142,15 @@ df.loc[samples.index, 'species'] = samples.values
142142
# Define the inputs and outputs
143143
X = df.drop(columns=['species', 'species_id'])
144144
y = df['species']
145-
y_onehot = pd.get_dummies(y, columns=model.classes_)
146145

147146
# Fit the model
148147
model = LogisticRegression(max_iter=200)
149148
model.fit(X, y)
150149
y_scores = model.predict_proba(X)
151150

151+
# One hot encode the labels in order to plot them
152+
y_onehot = pd.get_dummies(y, columns=model.classes_)
153+
152154
# Create an empty figure, and iteratively add new lines
153155
# every time we compute a new class
154156
fig = go.Figure()
@@ -272,4 +274,4 @@ fig.show()
272274
Learn more about `px`, `px.area`, `px.hist`:
273275
* https://plot.ly/python/histograms/
274276
* https://plot.ly/python/filled-area-plots/
275-
* https://plot.ly/python/line-charts/
277+
* https://plot.ly/python/line-charts/

0 commit comments

Comments
 (0)