Changeset 9419:0b5585abbc35 in orange


Ignore:
Timestamp:
12/28/11 13:13:54 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
d96f8f780efee463a0430424ddeee3cdef1db1b8
Message:

Fixed an error when input data has to few continuous variables.
Don't compute class correlations with itself.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Prototypes/OWCorrelations.py

    r9356 r9419  
    33<description>Compute all pairwise attribute correlations</description> 
    44<icon>icons/Correlations.png</icon> 
     5<contact>ales.erjavec(@ at @)fri.uni-lj.si</contact> 
    56 
    67""" 
     
    258259        self.information(0) 
    259260        self.data = data 
    260         if data is not None and len(data.domain) > 2: 
     261        if data is not None and len(filter(is_continuous, data.domain)) >= 2: 
    261262            self.set_variables_list(data) 
    262263            self.selected_index = None 
     
    278279                 
    279280        elif data is not None: 
    280             self.information(0, "Need data with at least 2 variables.") 
     281            self.data = None 
     282            self.information(0, "Need data with at least 2 continuous variables.") 
    281283             
    282284        self.commit_if() 
     
    304306             
    305307        elif is_continuous(self.target_variable): 
    306             p_corr = target_pearson_correlations(self.data, self.cont_vars, self.target_variable) 
    307             s_corr = target_spearman_correlations(self.data, self.cont_vars, self.target_variable) 
     308            vars = [v for v in self.cont_vars if v != self.target_variable] 
     309            p_corr = target_pearson_correlations(self.data, vars, self.target_variable) 
     310            s_corr = target_spearman_correlations(self.data, vars, self.target_variable) 
    308311            correlations = map(list, zip(p_corr, s_corr)) 
    309             self.set_target_correlations(correlations, self.cont_vars, self.target_variable) 
     312            self.set_target_correlations(correlations, vars, self.target_variable) 
    310313             
    311314    def set_all_pairwise_matrix(self, matrix, vars=None): 
     
    368371     
    369372    def on_corr_type_change(self): 
    370 #        self.spliter.setOrientation(Qt.Vertical if self.correlations_type < 2 else Qt.Horizontal) 
    371         curr_selection = self.selected_vars 
    372         self.clear_computed() 
    373         self.run() 
    374          
    375         if curr_selection: 
    376             try: 
    377                 self.set_selected_vars(*curr_selection) 
    378             except Exception, ex: 
    379                 import traceback 
    380                 traceback.print_exc() 
    381          
    382         self.commit_if() 
     373        if self.data is not None: 
     374            curr_selection = self.selected_vars 
     375            self.clear_computed() 
     376            self.run() 
     377             
     378            if curr_selection: 
     379                try: 
     380                    self.set_selected_vars(*curr_selection) 
     381                except Exception, ex: 
     382                    import traceback 
     383                    traceback.print_exc() 
     384             
     385            self.commit_if() 
    383386         
    384387    def on_table_selection_change(self, selected, deselected): 
Note: See TracChangeset for help on using the changeset viewer.