olpy/classifiers/ogd.py
def _update(self, x: np.ndarray, y: int):
        """Updates the weight vector in case a mistake occured.
        
        When presented with a data point, this method evaluates
        the error and based on the result, updates or not the 
        weights vector.

        Args:
            x (:obj:`np.ndarray` or `list`): An array representing
                one single data point. Array needs to be 2D.
            y (`int`): Output value for the data point. Takes value
                between 1 and -1.

        Returns:
            None

        Raises:
            IndexError: if the value x is not 2D.
        """
        decision = self.weights.dot(x)
        prediction = np.sign(decision)
        c = self._C / math.sqrt(self._t)

        # Changed the parameters to call the loss function as it seems they
        # expect at least two values
        if self._loss_function == hinge_loss:
            loss = self._loss_function([y, -y], [decision, -decision])
        else:
            loss = self._loss_function([y], [prediction])

        if loss > 0:
            if self._loss_function == log_loss:
                self.weights = (self.weights 
                                + c * y * x 
                                * (1 / (1 + math.exp(y * decision)))
                                * self.class_weight_[y])
            elif self._loss_function == mean_squared_error:
                self.weights = (self.weights 
                                - c * ((decision - y) 
                                    * x * self.class_weight_[y]))
            else:
                self.weights = self.weights + c * y * x

        self._t += 1
Updates the weight vector in case a mistake occured.
        
        When presented with a data point, this method evaluates
        the error and based on the result, updates or not the 
        weights vector.

        Args:
            x (:obj:`np.ndarray` or `list`): An array representing
                one single data point. Array needs to be 2D.
            y (`int`): Output value for the data point. Takes value
                between 1 and -1.

        Returns:
            None

        Raises:
            IndexError: if the value x is not 2D.
        
Updates the weight vector in case a mistake occured.
When presented with a data point, this method evaluates
the error and based on the result, updates or not the
weights vector.
Updates the weight vector in case a mistake occured . When presented with a data point this method evaluates the error and based on the result updates or not the weights vector .
def _update(self, x: np.ndarray, y: int):
        decision = self.weights.dot(x)
        prediction = np.sign(decision)
        c = self._C / math.sqrt(self._t)
        if self._loss_function == hinge_loss:
            loss = self._loss_function([y, -y], [decision, -decision])
        else:
            loss = self._loss_function([y], [prediction])
        if loss > 0:
            if self._loss_function == log_loss:
                self.weights = (self.weights 
                                + c * y * x 
                                * (1 / (1 + math.exp(y * decision)))
                                * self.class_weight_[y])
            elif self._loss_function == mean_squared_error:
                self.weights = (self.weights 
                                - c * ((decision - y) 
                                    * x * self.class_weight_[y]))
            else:
                self.weights = self.weights + c * y * x
        self._t += 1
def _update ( self , x : np . ndarray , y : int ) : decision = self . weights . dot ( x ) prediction = np . sign ( decision ) c = self . _C / math . sqrt ( self . _t ) if self . _loss_function == hinge_loss : loss = self . _loss_function ( [ y , - y ] , [ decision , - decision ] ) else : loss = self . _loss_function ( [ y ] , [ prediction ] ) if loss > 0 : if self . _loss_function == log_loss : self . weights = ( self . weights + c * y * x * ( 1 / ( 1 + math . exp ( y * decision ) ) ) * self . class_weight_ [ y ] ) elif self . _loss_function == mean_squared_error : self . weights = ( self . weights - c * ( ( decision - y ) * x * self . class_weight_ [ y ] ) ) else : self . weights = self . weights + c * y * x self . _t += 1
Updates the weight vector in case a mistake occured.
Updates the weight vector in case a mistake occured .
"""Updates the weight vector in case a mistake occured.
        
        When presented with a data point, this method evaluates
        the error and based on the result, updates or not the 
        weights vector.

        Args:
            x (:obj:`np.ndarray` or `list`): An array representing
                one single data point. Array needs to be 2D.
            y (`int`): Output value for the data point. Takes value
                between 1 and -1.

        Returns:
            None

        Raises:
            IndexError: if the value x is not 2D.
        """ # Changed the parameters to call the loss function as it seems they # expect at least two values
None
if the value x is not 2D.
if the value x is not 2D .
IndexError
self
x
np.ndarray
y
int
Output value for the data point. Takes value
between 1 and -1.
Output value for the data point . Takes value between 1 and - 1 .
x (
`np.ndarray` or `list`): An array representing
one single data point. Array needs to be 2D.
` np . ndarray ` or ` list ` ) : An array representing one single data point . Array needs to be 2D .