Softmax regression is a generalization of logistic regression to multiple classes.
Softmax regression is also known as "multinomial logistic regression". There are a set weights for each class, hence the
weights attribute is a nested
collections.defaultdict. The main advantage of using this instead of a one-vs-all logistic regression is that the probabilities will be calibrated. Moreover softmax regression is more robust to outliers.
optimizer (optim.base.Optimizer) – defaults to
The sequential optimizer used to tune the weights.
loss (optim.losses.MultiClassLoss) – defaults to
The loss function to optimize for.
l2 – defaults to
Amount of L2 regularization used to push weights towards 0.
- weights (collections.defaultdict)
>>> from river import datasets >>> from river import evaluate >>> from river import linear_model >>> from river import metrics >>> from river import optim >>> from river import preprocessing >>> dataset = datasets.ImageSegments() >>> model = preprocessing.StandardScaler() >>> model |= linear_model.SoftmaxRegression() >>> metric = metrics.MacroF1() >>> evaluate.progressive_val_score(dataset, model, metric) MacroF1: 81.88%
Return a fresh estimator with the same parameters.
The clone has the same parameters but has not been updated with any data. This works by looking at the parameters from the class signature. Each parameter is either - recursively cloned if it's a River classes. - deep-copied via
copy.deepcopy if not. If the calling object is stochastic (i.e. it accepts a seed parameter) and has not been seeded, then the clone will not be idempotent. Indeed, this method's purpose if simply to return a new instance with the same input parameters.
Update the model with a set of features
x and a label
- x (dict)
- y (Union[bool, str, int])
Predict the label of a set of features
- x (dict)
typing.Union[bool, str, int]: The predicted label.
Predict the probability of each label for a dictionary of features
- x (dict)
typing.Dict[typing.Union[bool, str, int], float]: A dictionary that associates a probability which each label.