Skip to content

Commit 2c3e1fd

Browse files
Shuowei LishuoweilGarrettWu
authored
docs: add linear model example (#1235)
* docs: add linear model example * chore: add experimental series.blob.display() function (#1232) * add an extra setting to set display prgress bar to None * docs: add KMeans example (#1234) * docs: add KMeans example * fix test * skip non deterministic examples * docs: add examples for ml PCA and SimpleImputer (#1236) * docs: add examples for ml PCA and SimpleImputer * fix * fix * fix doctest bug * add extra lines to fix docs bug * fix docstring bug * remove an extra line --------- Co-authored-by: Shuowei Li <[email protected]> Co-authored-by: Garrett Wu <[email protected]>
1 parent 50648e4 commit 2c3e1fd

File tree

1 file changed

+24
-0
lines changed
  • third_party/bigframes_vendored/sklearn/linear_model

1 file changed

+24
-0
lines changed

third_party/bigframes_vendored/sklearn/linear_model/_base.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,30 @@ class LinearRegression(RegressorMixin, LinearModel):
6262
to minimize the residual sum of squares between the observed targets in
6363
the dataset, and the targets predicted by the linear approximation.
6464
65+
**Examples:**
66+
67+
>>> from bigframes.ml.linear_model import LinearRegression
68+
>>> import bigframes.pandas as bpd
69+
>>> bpd.options.display.progress_bar = None
70+
>>> X = bpd.DataFrame({ \
71+
"feature0": [20, 21, 19, 18], \
72+
"feature1": [0, 1, 1, 0], \
73+
"feature2": [0.2, 0.3, 0.4, 0.5]})
74+
>>> y = bpd.DataFrame({"outcome": [0, 0, 1, 1]})
75+
>>> # Create the linear model
76+
>>> model = LinearRegression()
77+
>>> model.fit(X, y)
78+
LinearRegression()
79+
80+
>>> # Score the model
81+
>>> score = model.score(X, y)
82+
>>> print(score) # doctest:+SKIP
83+
mean_absolute_error mean_squared_error mean_squared_log_error \
84+
0 0.022812 0.000602 0.00035
85+
median_absolute_error r2_score explained_variance
86+
0 0.015077 0.997591 0.997591
87+
88+
6589
Args:
6690
optimize_strategy (str, default "auto_strategy"):
6791
The strategy to train linear regression models. Possible values are

0 commit comments

Comments
 (0)