8000 DOC Add example to linear_model.PoissonRegressor (#17453) · scikit-learn/scikit-learn@74b445e · GitHub
[go: up one dir, main page]

Skip to content

Commit 74b445e

Browse files
nuka137thomasjpfan
andauthored
DOC Add example to linear_model.PoissonRegressor (#17453)
* [WIP]: Add examples to linear_model.PoissonRegressor * Address review * Address review * Apply suggestions from code review Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> * Remove numpy import Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
1 parent aeffba3 commit 74b445e

File tree

1 file changed

+17
-0
lines changed
  • sklearn/linear_model/_glm

1 file changed

+17
-0
lines changed

sklearn/linear_model/_glm/glm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,23 @@ class PoissonRegressor(GeneralizedLinearRegressor):
430430
431431
n_iter_ : int
432432
Actual number of iterations used in the solver.
433+
434+
Examples
435+
----------
436+
>>> from sklearn import linear_model
437+
>>> clf = linear_model.PoissonRegressor()
438+
>>> X = [[1, 2], [2, 3], [3, 4], [4, 3]]
439+
>>> y = [12, 17, 22, 21]
440+
>>> clf.fit(X, y)
441+
PoissonRegressor()
442+
>>> clf.score(X, y)
443+
0.990...
444+
>>> clf.coef_
445+
array([0.121..., 0.158...])
446+
>>> clf.intercept_
447+
2.088...
448+
>>> clf.predict([[1, 1], [3, 4]])
449+
array([10.676..., 21.875...])
433450
"""
434451
def __init__(self, *, alpha=1.0, fit_intercept=True, max_iter=100,
435452
tol=1e-4, warm_start=False, verbose=0):

0 commit comments

Comments
 (0)
0