python/methylnet/interpretation_classes.py
def compute_distances(self, metric='cosine', trim=0.):
        """Compute distance matrix between classes by average distances between points of classes.

        Parameters
        ----------
        metric : str
            Scikit-learn distance metric.

        """
        from itertools import combinations
        from sklearn.metrics import pairwise_distances
        from scipy.stats import trim_mean
        distance_calculator = lambda x,y: trim_mean(pairwise_distances(x,y,metric=metric).flatten(),trim)#.mean()
        self.distances = pd.DataFrame(0,index=self.classes,columns=self.classes)

        for i,j in combinations(self.classes,r=2):
            x1=self.embeddings.loc[self.col[self.col==i].index]
            x2=self.embeddings.loc[self.col[self.col==j].index]
            self.distances.loc[i,j]=distance_calculator(x1,x2)
            self.distances.loc[j,i]=self.distances.loc[i,j]
Compute distance matrix between classes by average distances between points of classes.

        Parameters
        ----------
        metric : str
            Scikit-learn distance metric.

        
Compute distance matrix between classes by average distances between points of classes.
Parameters

metric : str
Scikit-learn distance metric.
Compute distance matrix between classes by average distances between points of classes . Parameters metric : str Scikit - learn distance metric .
def compute_distances(self, metric='cosine', trim=0.):
        from itertools import combinations
        from sklearn.metrics import pairwise_distances
        from scipy.stats import trim_mean
        distance_calculator = lambda x,y: trim_mean(pairwise_distances(x,y,metric=metric).flatten(),trim)
        self.distances = pd.DataFrame(0,index=self.classes,columns=self.classes)
        for i,j in combinations(self.classes,r=2):
            x1=self.embeddings.loc[self.col[self.col==i].index]
            x2=self.embeddings.loc[self.col[self.col==j].index]
            self.distances.loc[i,j]=distance_calculator(x1,x2)
            self.distances.loc[j,i]=self.distances.loc[i,j]
def compute_distances ( self , metric = 'cosine' , trim = 0. ) : from itertools import combinations from sklearn . metrics import pairwise_distances from scipy . stats import trim_mean distance_calculator = lambda x , y : trim_mean ( pairwise_distances ( x , y , metric = metric ) . flatten ( ) , trim ) self . distances = pd . DataFrame ( 0 , index = self . classes , columns = self . classes ) for i , j in combinations ( self . classes , r = 2 ) : x1 = self . embeddings . loc [ self . col [ self . col == i ] . index ] x2 = self . embeddings . loc [ self . col [ self . col == j ] . index ] self . distances . loc [ i , j ] = distance_calculator ( x1 , x2 ) self . distances . loc [ j , i ] = self . distances . loc [ i , j ]
Compute distance matrix between classes by average distances between points of classes.
Compute distance matrix between classes by average distances between points of classes .
"""Compute distance matrix between classes by average distances between points of classes.

        Parameters
        ----------
        metric : str
            Scikit-learn distance metric.

        """ #.mean()
self
metric
trim