Example #1
0
 def reshape_value(self,value,row_index):
     reshaped_values = []
     
     if value == NONE_VALUE:        
         value = _exec_func_code(self.default_function_code,self.table,self,row_index)
     
     if self.has_class():
         if len(self.classes)>2: 
             for feature in self.classes:
                 if value == feature:
                     reshaped_values.append(1.0)
                 else:
                     reshaped_values.append(0.0)
         else: #Binary class
             if self.get_type() == TEXT_TYPE:
                 if value == self.common_value:
                     reshaped_values.append(1.0)
                 else:
                     reshaped_values.append(0.0)
             else:
                 reshaped_values.append(float(value))
     else: # no class
         if self.get_type() == TEXT_TYPE: #text
             for feature in self.classes:
                 if feature in self.text_analyzer.build_analyzer()(unicode(value)) :
                     reshaped_values.append(1.0)
                 else:
                     reshaped_values.append(0.0)
         else: #numeric
             reshaped_values.append(float(value))
     
     return reshaped_values
Example #2
0
 def reshape_target(self,value,row_index):
     #if undefined value, then compute the default value function
     if value == NONE_VALUE:        
         value = _exec_func_code(self.default_function_code,self.table,self,row_index)
     
     #Convert TEXT target value as Int value for model compliance            
     if self.get_type() == TEXT_TYPE:
         assert self.has_class(),"Unclassed Text Feature cannot be a target"
         value = self.classes.index(value)
     return value