fn update_all(&mut self) -> Result<(), ()> {
        for (neigh, y, old_pred, old_error) in izip!(
            &self.neighbors,
            &self.labels,
            &mut self.predictions,
            &mut self.errors
        ) {
            let pred = neigh.predict(self.current_k)?;
            if pred == *old_pred {
                continue;
            }
            let error = if pred != *y { 1 } else { 0 };

            match (error, *old_error) {
                (1, 0) => self.k_error_count += 1,
                (0, 1) => self.k_error_count -= 1,
                // No need to update.
                _ => {}
            };

            *old_pred = pred;
            *old_error = error;
        }
        Ok(())
    }
/// Update all predictions and errors.
///
/// Called when when k changes.
Update all predictions and errors.
Called when when k changes.
Update all predictions and errors . Called when when k changes .
fn update_all(&mut self) -> Result<(), ()> {
        for (neigh, y, old_pred, old_error) in izip!(
            &self.neighbors,
            &self.labels,
            &mut self.predictions,
            &mut self.errors
        ) {
            let pred = neigh.predict(self.current_k)?;
            if pred == *old_pred {
                continue;
            }
            let error = if pred != *y { 1 } else { 0 };
            match (error, *old_error) {
                (1, 0) => self.k_error_count += 1,
                (0, 1) => self.k_error_count -= 1,
                // No need to update.
                _ => {}
            };
            *old_pred = pred;
            *old_error = error;
        }
        Ok(())
    }
fn update_all ( & mut self ) -> Result < ( ) , ( ) > { for ( neigh , y , old_pred , old_error ) in izip ! ( self neighbors self labels mut self predictions mut self errors ) { let pred = neigh . predict ( self . current_k ) ? ; if pred == * old_pred { continue ; } let error = if pred != * y { 1 } else { 0 } ; match ( error , * old_error ) { ( 1 , 0 ) => self . k_error_count += 1 , ( 0 , 1 ) => self . k_error_count -= 1 , // No need to update. _ => { } } ; * old_pred = pred ; * old_error = error ; } Ok ( ( ) ) }
Update all predictions and errors.
Update all predictions and errors .
&mut self
&mut self