Exemple #1
0
from model import rainFallRegressor

import time
import sys

dataset = sys.argv[1]

print "Model: ", dataset

dfTrain = pd.read_csv("./data/xTrain_" + dataset + ".csv")
yTrain = pd.read_csv("./data/yTrain_" + dataset + ".csv")

tstart = time.time()

subSet = yTrain.Id[int(len(yTrain) * .5)]

dfValid = dfTrain[dfTrain.Id > subSet]
yValid = yTrain[yTrain.Id > subSet]
dfTrain = dfTrain[dfTrain.Id <= subSet]
yTrain = yTrain[yTrain.Id <= subSet]

marshallPalmer = rainFallRegressor(eps=1e-5, nepoch=15)
marshallPalmer.resetRef()
marshallPalmer.fit(dfTrain, yTrain)
print marshallPalmer.score(dfValid, yValid['Expected'])

tstop = time.time()

print 'Time: ', tstop - tstart, ' sec'
Exemple #2
0
import numpy as np
import pandas as pd

dataset = "ref_zdr"

from model import rainFallRegressor


dfTest = pd.read_csv("./data/xTest_" + dataset + ".csv")


p = [-0.0056959094655 ,0.264798269811  ,-2.46924886623 , 1.82866      ]

marshallPalmer = rainFallRegressor(eps=1e-5, nepoch=15)
marshallPalmer.resetRefZdr()
marshallPalmer.c = p[0]
marshallPalmer.a1= p[1]
marshallPalmer.a2= p[2]
marshallPalmer.d = p[3]

pred = marshallPalmer.predict(dfTest)

dfPred = pd.DataFrame(range(717626), columns=[['Expected']])
dfPred.drop(0, inplace=True)
dfPred.Expected = pred
dfPred.fillna(dfPred.mean(), inplace=True)
dfPred['Id'] = dfPred.index
dfPred = dfPred[['Id','Expected']]

dfPred.to_csv("./data/submit_" + dataset + ".csv", index=False)