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
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
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`'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.
42
+
This example shows how to use `plotly.express`'s `trendline` parameter to train a simply Ordinary Least Square (OLS) for predicting the tips waiters will receive based on the value of the total bill.
43
43
44
44
```python
45
45
import plotly.express as px
@@ -88,7 +88,7 @@ from sklearn.linear_model import LinearRegression
88
88
from sklearn.model_selection import train_test_split
## 3D regression surface with `px.scatter_3d` and `go.Surface`
182
182
183
-
Visualize the decision plane of your model whenever you have more than one variable in your input data.
183
+
Visualize the decision plane of your model whenever you have more than one variable in your input data. Here, we will use [`sklearn.svm.SVR`](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html), which is a Support Vector Machine (SVM) model specifically designed for regression.
184
184
185
185
```python
186
186
import numpy as np
187
187
import plotly.express as px
188
188
import plotly.graph_objects as go
189
-
from sklearn.neighborsimportKNeighborsRegressor
189
+
from sklearn.svmimportSVR
190
190
191
191
mesh_size =.02
192
192
margin =0
@@ -197,8 +197,8 @@ X = df[['sepal_width', 'sepal_length']]
197
197
y = df['petal_width']
198
198
199
199
# Condition the model on sepal width and length, predict the petal width
200
-
knn=KNeighborsRegressor(10, weights='distance')
201
-
knn.fit(X, y)
200
+
model=SVR(C=1.)
201
+
model.fit(X, y)
202
202
203
203
# Create a mesh grid on which we will run our model
0 commit comments