Exemple #1
0
 def test_get_predicted_value(self):
     current_path = os.path.realpath(__file__)
     data_frame = robjects.DataFrame.from_csvfile(current_path[:current_path.rindex('/')] + '/../data/state.df')
     prediction_variable = 'Life.Exp'
     predictor_variables = ['Population', 'Income', 'Illiteracy', 'Murder', 'HS.Grad', 'Frost', 'Area']
     model = R_Helper.linear_regression_model(data_frame, prediction_variable, predictor_variables)
     mf_parameter_names_to_values = dict(R_Helper.get_parameter_values(model))
     mf_variable_name_to_value = {'Population': 1.0}
     self.assertEqual(
                     '%0.5f'%70.9432759115, 
                     '%0.5f'%R_Helper.get_predicted_value(mf_parameter_names_to_values, mf_variable_name_to_value)
                  )