Ejemplo n.º 1
0
from sklearn import metrics

qualities, combinations = cp.getCombinations()
ds, featuresNames = labanUtil.getPybrainDataSet()
inLayerSize = len(ds.getSample(0)[0])
outLayerSize = len(ds.getSample(0)[1])
splitProportion = 0.2
decay= 0.999995
myWeightdecay = 0.00015#0.99999
initialLearningrate= 0.01
hiddenSize = 150
epochs=3000
momentum=0#.25
#ds.nClasses = len(qualities)
tstdata, trndata = ds.splitWithProportion( splitProportion )
res = labanUtil.constructNet(inLayerSize, hiddenSize, outLayerSize)
n=res[0]
trainer = BackpropTrainer(n, trndata, learningrate=initialLearningrate,\
    lrdecay=decay, verbose=True, weightdecay=myWeightdecay, momentum=momentum)
description =  'ds '+ str(len(ds))+\
 ', h: '+ str(hiddenSize)+ \
 ', lr ' + str(initialLearningrate) 
description =   description+ ', decay ' +  str(decay) + ' sp: ' +   str(splitProportion) + \
' wd ' +  str(myWeightdecay)+ ' momentum ' + str(momentum)
print description
trnresults =[]
tstresults = []
q=5
for _ in range(epochs/q):
    #trainer.trainEpochs(1)
    trainer.trainUntilConvergence(dataset=trndata, \
Ejemplo n.º 2
0
    selector = selector.fit(X, y)
    accum += selector.pvalues_
selectedIndices = accum.argsort()[:selectedFeaureNum]
def transform(X):
    return X[:, selectedIndices]     
X, X_test =  transform(X), transform(X_test)
trndata, tstdata = labanUtil.fromXY2DS(X, Y), labanUtil.fromXY2DS(X_test, Y_test)

epochs=2000
hiddenSize=400
initialLearningrate=0.00004
decay=1
myWeightdecay=0
momentum=0.9

net = (labanUtil.constructNet(X.shape[1], hiddenSize, Y.shape[1]))[0]
cvResults = []
trainResults = []
#validResults=[]
testResults = []
totalTrainF1s=[]
totalTestf1 = []
sums=[]
lastTrainVec = np.zeros(Y.shape)
quanta=5
params = range(epochs/quanta)


for epochNum in params:
    validData, trndata = trndata.splitWithProportion( 0.2 )
    X, Y = labanUtil.getXYfromPybrainDS(trndata)