df_extensions/space.py
def composite_distance(self, normalize: bool = False):
        """
        Given all distances in joint space,
        calculate a composite.
        Set normalize to true to scale all distances between 0 and 1
        Shouldn't be needed where a product of previous rounds of normalization
        A scale factor of 2 for a column reduces distances by half
        """
        df = self._obj.copy()

        def normalize_series(s: pd.Series):
            return s / s.max()

        cols = df.columns[2:]
        cols = [df[x] for x in cols]

        if normalize:
            cols = [normalize_series(x) for x in cols]

        squared_cols = [x ** 2 for x in cols]
        res = reduce(pd.Series.add, squared_cols)  # add squared cols
        res = res.apply(np.sqrt)  # get square root

        ndf = df[df.columns[:2]]
        ndf["distance"] = res
        return ndf

        Given all distances in joint space,
        calculate a composite.
        Set normalize to true to scale all distances between 0 and 1
        Shouldn't be needed where a product of previous rounds of normalization
        A scale factor of 2 for a column reduces distances by half
        
Given all distances in joint space,
calculate a composite.
Set normalize to true to scale all distances between 0 and 1
Shouldn't be needed where a product of previous rounds of normalization
A scale factor of 2 for a column reduces distances by half
Given all distances in joint space calculate a composite . Set normalize to true to scale all distances between 0 and 1 Shouldn ' t be needed where a product of previous rounds of normalization A scale factor of 2 for a column reduces distances by half
def composite_distance(self, normalize: bool = False):
        df = self._obj.copy()
        def normalize_series(s: pd.Series):
            return s / s.max()
        cols = df.columns[2:]
        cols = [df[x] for x in cols]
        if normalize:
            cols = [normalize_series(x) for x in cols]
        squared_cols = [x ** 2 for x in cols]
        res = reduce(pd.Series.add, squared_cols)  
        res = res.apply(np.sqrt)  
        ndf = df[df.columns[:2]]
        ndf["distance"] = res
        return ndf
def composite_distance ( self , normalize : bool = False ) : df = self . _obj . copy ( ) def normalize_series ( s : pd . Series ) : return s / s . max ( ) cols = df . columns [ 2 : ] cols = [ df [ x ] for x in cols ] if normalize : cols = [ normalize_series ( x ) for x in cols ] squared_cols = [ x ** 2 for x in cols ] res = reduce ( pd . Series . add , squared_cols ) res = res . apply ( np . sqrt ) ndf = df [ df . columns [ : 2 ] ] ndf [ "distance" ] = res return ndf
Given all distances in joint space,
calculate a composite.
Given all distances in joint space calculate a composite .
"""
        Given all distances in joint space,
        calculate a composite.
        Set normalize to true to scale all distances between 0 and 1
        Shouldn't be needed where a product of previous rounds of normalization
        A scale factor of 2 for a column reduces distances by half
        """ # add squared cols # get square root
self
normalize
bool