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
+43-27Lines changed: 43 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,16 +213,16 @@ fig.show()
213
213
## Prediction Error Plots
214
214
215
215
216
-
### Simple Prediction Error
216
+
### Simple actual vs predicted plot
217
217
218
218
```python
219
219
import plotly.express as px
220
220
import plotly.graph_objects as go
221
221
from sklearn.linear_model import LinearRegression
222
222
223
223
df = px.data.iris()
224
-
X = df.loc[train_idx, ['sepal_width', 'sepal_length']]
225
-
y = df.loc[train_idx, 'petal_width']
224
+
X = df[['sepal_width', 'sepal_length']]
225
+
y = df['petal_width']
226
226
227
227
# Condition the model on sepal width and length, predict the petal width
228
228
model = LinearRegression()
@@ -238,7 +238,7 @@ fig.add_shape(
238
238
fig.show()
239
239
```
240
240
241
-
### Augmented Prediction Error analysis using `plotly.express`
241
+
### Augmented prediction error analysis using `plotly.express`
242
242
243
243
```python
244
244
import plotly.express as px
@@ -276,7 +276,7 @@ fig.add_shape(
276
276
fig.show()
277
277
```
278
278
279
-
## Residual Plots
279
+
## Residual plots
280
280
281
281
Just like prediction error plots, it's easy to visualize your prediction residuals in just a few lines of codes using `plotly.express` built-in capabilities.
282
282
@@ -312,28 +312,34 @@ fig = px.scatter(
312
312
fig.show()
313
313
```
314
314
315
-
## Grid Search Visualization using `px` facets
315
+
## Grid search visualization using `px.density_heatmap` and `px.box`
316
+
317
+
In this example, we show how to visualize the results of a grid search on a `DecisionTreeRegressor`. The first plot shows how to visualize the score of each model parameter on individual splits (grouped using facets). The second plot aggregates the results of all splits such that each box represents a single model.
316
318
317
319
```python
320
+
import numpy as np
318
321
import pandas as pd
319
322
import plotly.express as px
320
323
import plotly.graph_objects as go
321
324
from sklearn.model_selection import GridSearchCV
322
325
from sklearn.tree import DecisionTreeRegressor
323
326
324
-
N_FOLD=5
327
+
N_FOLD=6
325
328
329
+
# Load and shuffle dataframe
326
330
df = px.data.iris()
327
-
X = df.loc[train_idx, ['sepal_width', 'sepal_length']]
0 commit comments