Created
December 21, 2022 13:14
-
-
Save kylegallatin/df961e54f05bf21ba790068c2bdaae9d to your computer and use it in GitHub Desktop.
Training a logistic regression model with River
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from river import linear_model, compose, preprocessing, metrics | |
# create logistic regression model with a standard scaler | |
model = compose.Pipeline( | |
preprocessing.StandardScaler(), | |
linear_model.LogisticRegression() | |
) | |
# use ROCAUC to evaluate our model | |
metric = metrics.ROCAUC() | |
# import the toy dataset for classifying phishing websites | |
dataset = datasets.Phishing() | |
for x, y in dataset: | |
y_pred = model.predict_proba_one(x) # get predicted probability | |
model.learn_one(x, y) # train on a single example | |
metric.update(y, y_pred) # update rocauc | |
print(metric) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment