output_files = [] output_files.append("file,mse,parameters") helpers.dump_results(output_files, results_folder,model) for f in csv_input_files: try : # fetching input file data dataframe_expect = pandas.read_csv(f) value = np.array(dataframe_expect['value']) timestamp = np.array(dataframe_expect['timestamp']) try : label = np.array(dataframe_expect['label']) except KeyError: print "Warnning :["+f+"] No `label` colomn found data set without labels !. Assumes there are no anomolies" label = np.zeros(len(value)) dataframe_predction = pandas.read_csv(helpers.get_result_file_name(f,results_folder,model)) prediction = np.array(dataframe_predction['prediction']) params = "training_size="+str(tesing_start) file_not_found = False except IOError: file_not_found = True print("Warnning :["+helpers.get_result_file_name(f,results_folder,model)+"] File not found !") if file_not_found: out_file = helpers.get_result_file_name(f, results_folder,model) output_files.append( helpers.get_result_dump_name(out_file) +",n/a,n/a" ) helpers.dump_results(output_files, results_folder,model) else : training = np.ones(tesing_start) testing = np.zeros(len(value)-tesing_start)
data = { 'value': value, 'prediction_training': training_colomn, 'label': label } colomn_arrangement = ['value', 'prediction_training', 'label'] for i in range(no_of_prediction_points): prediction[i] = np.append(training, prediction[i]) data['prediction_' + str(i)] = prediction[i] colomn_arrangement.append('prediction_' + str(i)) dataframe_out = pandas.DataFrame(data, index=timestamp) dataframe_out.index.name = "timestamp" dataframe_out = dataframe_out[colomn_arrangement] out_file = helpers.get_result_file_name(f, csv_output_directory, m) dataframe_out.to_csv(out_file) testing_value = value[testing_start:] mse = helpers.MSE_multipoint(testing_value, testing_prediction, no_of_prediction_points) output_files.append( helpers.get_result_dump_name(out_file) + "," + str(mse) + "," + params) helpers.dump_results(output_files, csv_output_directory, m) print("##### [" + m + "]" + str(count) + " CSV input File processed #####") count += 1 print("##### " + m + " done ! #####")
output_files.append("file,mse,parameters") helpers.dump_results(output_files, results_folder, model) for f in csv_input_files: try: # fetching input file data dataframe_expect = pandas.read_csv(f) value = np.array(dataframe_expect['value']) timestamp = np.array(dataframe_expect['timestamp']) try: label = np.array(dataframe_expect['label']) except KeyError: print "Warnning :[" + f + "] No `label` colomn found data set without labels !. Assumes there are no anomolies" label = np.zeros(len(value)) dataframe_predction = pandas.read_csv( helpers.get_result_file_name(f, results_folder, model)) prediction = np.array(dataframe_predction['prediction']) params = "training_size=" + str(tesing_start) file_not_found = False except IOError: file_not_found = True print("Warnning :[" + helpers.get_result_file_name(f, results_folder, model) + "] File not found !") if file_not_found: out_file = helpers.get_result_file_name(f, results_folder, model) output_files.append( helpers.get_result_dump_name(out_file) + ",n/a,n/a") helpers.dump_results(output_files, results_folder, model) else: