def test_get_rf_feature_scores(self):
        x, outcomes = utilities.load_flu_data()

        def classify(data):
            #get the output for deceased population
            result = data['deceased population region 1']

            #make an empty array of length equal to number of cases
            classes = np.zeros(result.shape[0])

            #if deceased population is higher then 1.000.000 people, classify as 1
            classes[result[:, -1] > 1000000] = 1

            return classes

        y = classify(outcomes)

        scores, forest = fs.get_rf_feature_scores(
            x, y, mode=RuleInductionType.CLASSIFICATION, random_state=10)

        self.assertEqual(len(scores), len(x.columns) - 3)
        self.assertTrue(isinstance(forest, RandomForestClassifier))

        self.assertRaises(ValueError,
                          fs.get_rf_feature_scores,
                          x,
                          y,
                          mode='illegal argument')

        y = outcomes['deceased population region 1'][:, -1]
        scores, forest = fs.get_rf_feature_scores(
            x, y, mode=RuleInductionType.REGRESSION, random_state=10)

        self.assertEqual(len(scores), len(x.columns) - 3)
        self.assertTrue(isinstance(forest, RandomForestRegressor))
 def test_get_rf_feature_scores(self):
     x, outcomes = test_utilities.load_flu_data()
             
     def classify(data):
         #get the output for deceased population
         result = data['deceased population region 1']
         
         #make an empty array of length equal to number of cases 
         classes =  np.zeros(result.shape[0])
         
         #if deceased population is higher then 1.000.000 people, classify as 1 
         classes[result[:, -1] > 1000000] = 1
         
         return classes
     
     y = classify(outcomes)
             
     scores, forest = fs.get_rf_feature_scores(x,y, mode=CLASSIFICATION,
                                               random_state=10)
     
     self.assertEqual(len(scores), len(x.dtype.fields))
     self.assertTrue(isinstance(forest, RandomForestClassifier))
     
     
     self.assertRaises(ValueError, fs.get_rf_feature_scores, x,y, 
                       mode='illegal argument')
     
     y = outcomes['deceased population region 1'][:,-1]
     scores, forest = fs.get_rf_feature_scores(x,y, mode=REGRESSION, 
                                               random_state=10)
     
     self.assertEqual(len(scores), len(x.dtype.fields))
     self.assertTrue(isinstance(forest, RandomForestRegressor))