som.py
def _update(self, sample):
        '''
        the update of the SOM - main part
        finding the closest prototype
        update of the whole map
        '''
        
        error = np.argmin(np.sum((sample - self.somap)**2, axis=1))
        er = np.min(np.sqrt(np.sum((sample - self.somap)**2, axis=1)))
        p_vec = self.q_lookup(error)
        self.r = np.max((self.r,er))
        self.epsilon = er/self.r
        
        for q in range(self.size**2):
            q_vec = self.q_lookup(q)
            temp_diff = (sample - self.somap[q]) # this accounts for the distance in the samples space
            temp_h =  self.h_vec(q_vec, p_vec)       # this accounts for the distance in the map space
            update = self.epsilon * temp_h * temp_diff
            self.somap[q] += update.astype('float64')

        the update of the SOM - main part
        finding the closest prototype
        update of the whole map
        
the update of the SOM - main part
finding the closest prototype
update of the whole map
the update of the SOM - main part finding the closest prototype update of the whole map
def _update(self, sample):
        error = np.argmin(np.sum((sample - self.somap)**2, axis=1))
        er = np.min(np.sqrt(np.sum((sample - self.somap)**2, axis=1)))
        p_vec = self.q_lookup(error)
        self.r = np.max((self.r,er))
        self.epsilon = er/self.r
        for q in range(self.size**2):
            q_vec = self.q_lookup(q)
            temp_diff = (sample - self.somap[q]) 
            temp_h =  self.h_vec(q_vec, p_vec)       
            update = self.epsilon * temp_h * temp_diff
            self.somap[q] += update.astype('float64')
def _update ( self , sample ) : error = np . argmin ( np . sum ( ( sample - self . somap ) ** 2 , axis = 1 ) ) er = np . min ( np . sqrt ( np . sum ( ( sample - self . somap ) ** 2 , axis = 1 ) ) ) p_vec = self . q_lookup ( error ) self . r = np . max ( ( self . r , er ) ) self . epsilon = er / self . r for q in range ( self . size ** 2 ) : q_vec = self . q_lookup ( q ) temp_diff = ( sample - self . somap [ q ] ) temp_h = self . h_vec ( q_vec , p_vec ) update = self . epsilon * temp_h * temp_diff self . somap [ q ] += update . astype ( 'float64' )
the update of the SOM - main part
finding the closest prototype
update of the whole map
the update of the SOM - main part finding the closest prototype update of the whole map
'''
        the update of the SOM - main part
        finding the closest prototype
        update of the whole map
        ''' # this accounts for the distance in the samples space # this accounts for the distance in the map space
self
sample