-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathNNRegPred.py
38 lines (28 loc) · 921 Bytes
/
NNRegPred.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import cPickle as pickle
import pandas as pd
from math import sqrt
from pybrain.datasets.supervised import SupervisedDataSet as SDS
from sklearn.metrics import mean_squared_error as MSE
from Confuse import main
model_file = 'model.pkl'
output_predictions_file = 'predictions.txt'
X2 = pd.read_csv('Test/Test_Combine.csv', usecols=[
'T', 'TM', 'Tm', 'SLP', 'H', 'VV', 'V', 'VM'])
Y2 = pd.read_csv('Test/Test_Combine.csv', usecols=['PM 2.5'])
X2 = X2.values
Y2 = Y2.values
net = pickle.load(open(model_file, 'rb'))
y_test_dummy = np.zeros(Y2.shape)
input_size = X2.shape[1]
target_size = X2.shape[1]
ds = SDS(input_size, target_size)
ds.setField('input', X2)
ds.setField('target', y_test_dummy)
p = net.activateOnDataset(ds)
mse = MSE(Y2, p)
rmse = sqrt(mse)
print "testing RMSE:", rmse
print "testing MSE: ", mse
main(Y2, p)
np.savetxt(output_predictions_file, p, fmt='%.6f')