pub fn hash_bag<'a>(&self, features: impl IntoIterator<Item = &'a BitArray<B>>) -> BitArray<H> {
        let mut counts = vec![0isize; H * 8];
        let mut num_features = 0usize;
        for feature in features {
            for (ix, word) in self.codewords.iter().enumerate() {
                // This makes sure to alternate between less than and less than or equal to every other codeword.
                counts[ix] +=
                    (((feature.distance(word) <= Self::threshold()) as isize) << 1).wrapping_sub(1);
            }
            num_features += 1;
        }
        // Correct for the natural imbalance in ones caused by the hamming spheres being slightly
        // above half the volume. The more features in the bag, the more correct (and balanced) the result will be.
        let correction = (num_features as f64 * -self.imbalance + 0.5) as isize;
        for count in &mut counts {
            *count += correction;
        }
        let mut hash = BitArray::zeros();
        for ix in 0..H * 8 {
            hash[ix >> 3] |= (counts[ix].is_positive() as u8) << (ix & 0b111);
        }
        hash
    }
/// Convert the input features into a hash.
Convert the input features into a hash.
Convert the input features into a hash .
pub fn hash_bag<'a>(&self, features: impl IntoIterator<Item = &'a BitArray<B>>) -> BitArray<H> {
        let mut counts = vec![0isize; H * 8];
        let mut num_features = 0usize;
        for feature in features {
            for (ix, word) in self.codewords.iter().enumerate() {
                // This makes sure to alternate between less than and less than or equal to every other codeword.
                counts[ix] +=
                    (((feature.distance(word) <= Self::threshold()) as isize) << 1).wrapping_sub(1);
            }
            num_features += 1;
        }
        // Correct for the natural imbalance in ones caused by the hamming spheres being slightly
        // above half the volume. The more features in the bag, the more correct (and balanced) the result will be.
        let correction = (num_features as f64 * -self.imbalance + 0.5) as isize;
        for count in &mut counts {
            *count += correction;
        }
        let mut hash = BitArray::zeros();
        for ix in 0..H * 8 {
            hash[ix >> 3] |= (counts[ix].is_positive() as u8) << (ix & 0b111);
        }
        hash
    }
pub fn hash_bag < ' a > ( & self , features : impl IntoIterator < Item = & ' a BitArray < B > > ) -> BitArray < H > { let mut counts = vec ! [ 0isize H 8 ] ; let mut num_features = 0usize ; for feature in features { for ( ix , word ) in self . codewords . iter ( ) . enumerate ( ) { // This makes sure to alternate between less than and less than or equal to every other codeword. counts [ ix ] += ( ( ( feature . distance ( word ) <= Self :: threshold ( ) ) as isize ) << 1 ) . wrapping_sub ( 1 ) ; } num_features += 1 ; } // Correct for the natural imbalance in ones caused by the hamming spheres being slightly // above half the volume. The more features in the bag, the more correct (and balanced) the result will be. let correction = ( num_features as f64 * - self . imbalance + 0.5 ) as isize ; for count in & mut counts { * count += correction ; } let mut hash = BitArray :: zeros ( ) ; for ix in 0 .. H * 8 { hash [ ix >> 3 ] |= ( counts [ ix ] . is_positive ( ) as u8 ) << ( ix & 0b111 ) ; } hash }
Convert the input features into a hash.
Convert the input features into a hash .
&self
features
impl IntoIterator<Item = &'a BitArray<B>>
&self
features
impl IntoIterator<Item = &'a BitArray<B>>