(self)
return sorted(enumerate(attrs), key=key)
Return (in_domain_index, attr) pairs, ordered by method in SortBy combo
Return (in_domain_index, attr) pairs, ordered by method in SortBy combo
Return ( in_domain_index attr ) pairs ordered by method in SortBy combo
def get_ordered_attributes(self):
        """Return (in_domain_index, attr) pairs, ordered by method in SortBy combo"""
        if self.domain is None or not self.domain.attributes:
            return []

        attrs = self.domain.attributes
        sort_by = self.sort_index
        class_value = self.target_class_index

        if sort_by == SortBy.NO_SORTING:
            return list(enumerate(attrs))

        elif sort_by == SortBy.NAME:

            def key(x):
                _, attr = x
                return attr.name.lower()

        elif sort_by == SortBy.ABSOLUTE:

            def key(x):
                i, attr = x
                if attr.is_discrete:
                    ptp = self.points[i][class_value].ptp()
                else:
                    coef = np.abs(self.log_reg_coeffs_orig[i][class_value]).mean()
                    ptp = coef * np.ptp(self.log_reg_cont_data_extremes[i][class_value])
                return -ptp

        elif sort_by == SortBy.POSITIVE:

            def key(x):
                i, attr = x
                max_value = (self.points[i][class_value].max()
                             if attr.is_discrete else
                             np.mean(self.log_reg_cont_data_extremes[i][class_value]))
                return -max_value

        elif sort_by == SortBy.NEGATIVE:

            def key(x):
                i, attr = x
                min_value = (self.points[i][class_value].min()
                             if attr.is_discrete else
                             np.mean(self.log_reg_cont_data_extremes[i][class_value]))
                return min_value

        return sorted(enumerate(attrs), key=key)
def get_ordered_attributes ( self ) : if self . domain is None or not self . domain . attributes : return [ ] attrs = self . domain . attributes sort_by = self . sort_index class_value = self . target_class_index if sort_by == SortBy . NO_SORTING : return list ( enumerate ( attrs ) ) elif sort_by == SortBy . NAME : def key ( x ) : _ , attr = x return attr . name . lower ( ) elif sort_by == SortBy . ABSOLUTE : def key ( x ) : i , attr = x if attr . is_discrete : ptp = self . points [ i ] [ class_value ] . ptp ( ) else : coef = np . abs ( self . log_reg_coeffs_orig [ i ] [ class_value ] ) . mean ( ) ptp = coef * np . ptp ( self . log_reg_cont_data_extremes [ i ] [ class_value ] ) return - ptp elif sort_by == SortBy . POSITIVE : def key ( x ) : i , attr = x max_value = ( self . points [ i ] [ class_value ] . max ( ) if attr . is_discrete else np . mean ( self . log_reg_cont_data_extremes [ i ] [ class_value ] ) ) return - max_value elif sort_by == SortBy . NEGATIVE : def key ( x ) : i , attr = x min_value = ( self . points [ i ] [ class_value ] . min ( ) if attr . is_discrete else np . mean ( self . log_reg_cont_data_extremes [ i ] [ class_value ] ) ) return min_value return sorted ( enumerate ( attrs ) , key = key )