|
23 | 23 | class LogisticRegression(LinearClassifierMixin, BaseEstimator):
|
24 | 24 | """Logistic Regression (aka logit, MaxEnt) classifier.
|
25 | 25 |
|
| 26 | + >>> from bigframes.ml.linear_model import LogisticRegression |
| 27 | + >>> import bigframes.pandas as bpd |
| 28 | + >>> bpd.options.display.progress_bar = None |
| 29 | + >>> X = bpd.DataFrame({ \ |
| 30 | + "feature0": [20, 21, 19, 18], \ |
| 31 | + "feature1": [0, 1, 1, 0], \ |
| 32 | + "feature2": [0.2, 0.3, 0.4, 0.5]}) |
| 33 | + >>> y = bpd.DataFrame({"outcome": [0, 0, 1, 1]}) |
| 34 | + >>> # Create the LogisticRegression |
| 35 | + >>> model = LogisticRegression() |
| 36 | + >>> model.fit(X, y) |
| 37 | + LogisticRegression() |
| 38 | + >>> model.predict(X) # doctest:+SKIP |
| 39 | + predicted_outcome predicted_outcome_probs feature0 feature1 feature2 |
| 40 | + 0 0 [{'label': 1, 'prob': 3.1895929877221615e-07} ... 20 0 0.2 |
| 41 | + 1 0 [{'label': 1, 'prob': 5.662891265051953e-06} ... 21 1 0.3 |
| 42 | + 2 1 [{'label': 1, 'prob': 0.9999917826885262} {'l... 19 1 0.4 |
| 43 | + 3 1 [{'label': 1, 'prob': 0.9999999993659574} {'l... 18 0 0.5 |
| 44 | + 4 rows × 5 columns |
| 45 | +
|
| 46 | + [4 rows x 5 columns in total] |
| 47 | +
|
| 48 | + >>> # Score the model |
| 49 | + >>> score = model.score(X, y) |
| 50 | + >>> score # doctest:+SKIP |
| 51 | + precision recall accuracy f1_score log_loss roc_auc |
| 52 | + 0 1.0 1.0 1.0 1.0 0.000004 1.0 |
| 53 | + 1 rows × 6 columns |
| 54 | +
|
| 55 | + [1 rows x 6 columns in total] |
| 56 | +
|
26 | 57 | Args:
|
27 | 58 | optimize_strategy (str, default "auto_strategy"):
|
28 | 59 | The strategy to train logistic regression models. Possible values are
|
|
0 commit comments