class_docstr: Passive-aggressive learning for classification.
  
  Parameters
  ----------
  C
  mode
  eps
  learn_intercept
  
  Examples
  --------
  
  The following example is taken from [this blog post](https://www.bonaccorso.eu/2017/10/06/ml-algorithms-addendum-passive-aggressive-algorithms/).
  
  >>> from river import linear_model
  >>> from river import metrics
  >>> from river import stream
  >>> import numpy as np
  >>> from sklearn import datasets
  >>> from sklearn import model_selection
  
  >>> np.random.seed(1000)
  >>> X, y = datasets.make_classification(
  ...     n_samples=5000,
  ...     n_features=4,
  ...     n_informative=2,
  ...     n_redundant=0,
  ...     n_repeated=0,
  ...     n_classes=2,
  ...     n_clusters_per_class=2
  ... )
  
  >>> X_train, X_test, y_train, y_test = model_selection.train_test_split(
  ...     X,
  ...     y,
  ...     test_size=0.35,
  ...     random_state=1000
  ... )
  
  >>> model = linear_model.PAClassifier(
  ...     C=0.01,
  ...     mode=1
  ... )
  
  >>> for xi, yi in stream.iter_array(X_train, y_train):
  ...     model.learn_one(xi, yi)
  
  >>> metric = metrics.Accuracy() + metrics.LogLoss()
  
  >>> for xi, yi in stream.iter_array(X_test, y_test):
  ...     metric.update(yi, model.predict_proba_one(xi))
  
  >>> print(metric)
  Accuracy: 88.46%
  LogLoss: 0.325727...
  
  References
  ----------
  [^1]: [Crammer, K., Dekel, O., Keshet, J., Shalev-Shwartz, S. and Singer, Y., 2006. Online passive-aggressive algorithms. Journal of Machine Learning Research, 7(Mar), pp.551-585](http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf)
class_docstr_tok: ["Passive-aggressive","learning","for","classification",".","Parameters","--","--","--","--","--","C","mode","eps","learn_intercept","Examples","--","--","--","--","The","following","example","is","taken","from","[","this","blog","post","]","(","https",":","\/\/www.bonaccorso.eu\/2017\/10\/06\/ml-algorithms-addendum-passive-aggressive-algorithms\/",")",".",">",">",">","from","river","import","linear_model",">",">",">","from","river","import","metrics",">",">",">","from","river","import","stream",">",">",">","import","numpy","as","np",">",">",">","from","sklearn","import","datasets",">",">",">","from","sklearn","import","model_selection",">",">",">","np.random.seed","(","1000",")",">",">",">","X",",","y","=","datasets.make_classification","(","...","n_samples=5000",",","...","n_features=4",",","...","n_informative=2",",","...","n_redundant=0",",","...","n_repeated=0",",","...","n_classes=2",",","...","n_clusters_per_class=2","...",")",">",">",">","X_train",",","X_test",",","y_train",",","y_test","=","model_selection.train_test_split","(","...","X",",","...","y",",","...","test_size=0.35",",","...","random_state=1000","...",")",">",">",">","model","=","linear_model.PAClassifier","(","...","C=0.01",",","...","mode=1","...",")",">",">",">","for","xi",",","yi","in","stream.iter_array","(","X_train",",","y_train",")",":","...","model.learn_one","(","xi",",","yi",")",">",">",">","metric","=","metrics.Accuracy","(",")","+","metrics.LogLoss","(",")",">",">",">","for","xi",",","yi","in","stream.iter_array","(","X_test",",","y_test",")",":","...","metric.update","(","yi",",","model.predict_proba_one","(","xi",")",")",">",">",">","print","(","metric",")","Accuracy",":","88.46","%","LogLoss",":","0.325727","...","References","--","--","--","--","--","[","^1","]",":","[","Crammer",",","K.",",","Dekel",",","O.",",","Keshet",",","J.",",","Shalev-Shwartz",",","S.","and","Singer",",","Y.",",","2006",".","Online","passive-aggressive","algorithms",".","Journal","of","Machine","Learning","Research",",","7","(","Mar",")",",","pp.551-585","]","(","http",":","\/\/jmlr.csail.mit.edu\/papers\/volume7\/crammer06a\/crammer06a.pdf",")"]
code: def learn_one(self, x, y):
      y_pred = utils.math.dot(x, self.weights) + self.intercept
      tau = self.calc_tau(x, self.loss(y, y_pred))
      step = tau * (y or -1)  # y == False becomes -1
  
      for i, xi in x.items():
          self.weights[i] += step * xi
      if self.learn_intercept:
          self.intercept += step
  
imports: from __future__ import annotations
  import collections
  import numpy
  from river import base, optim, utils
label_desc: Use image node_id 2 for calling the PAClassifier obj's underlying member method code with example usage: obj.learn_one(x, y) without return types