You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/ml-regression.md
+68-33Lines changed: 68 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ jupyter:
39
39
### Ordinary Least Square (OLS) with `plotly.express`
40
40
41
41
42
-
This example shows how to use `plotly.express`to train a simply Ordinary Least Square (OLS) that can predict the tips servers will receive based on the value of the total bill.
42
+
This example shows how to use `plotly.express`'s `trendline` parameter to train a simply Ordinary Least Square (OLS) for predicting the tips servers will receive based on the value of the total bill.
43
43
44
44
```python
45
45
import plotly.express as px
@@ -108,7 +108,7 @@ fig.show()
108
108
109
109
## Comparing different kNN models parameters
110
110
111
-
Compare the performance of two different models on the same dataset. This can be easily combined with discrete color legends from `px`.
111
+
Compare the performance of two different models on the same dataset. This can be easily combined with discrete color legends from `px`, such as coloring by the assigned `sex`.
colors = ['Positive'if c >0else'Negative'for c in model.coef_]
217
240
241
+
fig = px.bar(
242
+
x=X.columns, y=model.coef_, color=colors,
243
+
color_discrete_sequence=['red', 'blue'],
244
+
labels=dict(x='Feature', y='Linear coefficient'),
245
+
title='Weight of each feature for predicting petal width'
246
+
)
218
247
fig.show()
219
248
```
220
249
221
250
## Prediction Error Plots
222
251
252
+
When you are working with very high-dimensional data, it is inconvenient to plot every dimension with your output `y`. Instead, you can use methods such as prediction error plots, which let you visualize how well your model does compared to the ground truth.
253
+
223
254
224
255
### Simple actual vs predicted plot
225
256
257
+
This example shows you the simplest way to compare the predicted output vs. the actual output. A good model will have most of the scatter dots near the diagonal black line.
258
+
226
259
```python
227
260
import plotly.express as px
228
261
import plotly.graph_objects as go
@@ -323,10 +356,10 @@ fig = px.scatter(
323
356
fig.show()
324
357
```
325
358
326
-
## Regularization visualization
359
+
## Visualize regularization across different cross-validation folds
327
360
328
361
329
-
### Plot alphas for individual folds
362
+
In this example, we show how to plot the results of various $\alpha$ penalization values from the results of cross-validation using scikit-learn's `LassoCV`. This is useful to see how much the error of the optimal alpha actually varies across CV folds.
0 commit comments