Beispiel #1
0
         newGroup = currentGroup
     else:
         print("\t\t current R2 =\t %.10f" % currentR2)
     print("\t\t best R2 =\t\t %.10f" % bestR2)
 print("** updated group structure is: %s" % (newGroup.partition, ))
 # if group structure is not empty, a new covariate can be added to an existing group
 # print oldGroup.size
 if oldGroup.size is not 0:
     print "** Add to an existing group: **"
     # can add new covariate to existing group
     for covariateInd in covariatesPool:
         for groupInd in np.arange(oldGroup.size)+1:
             # print oldGroup.partition
             print("\t try adding covariate %d " % covariateInd)
             print("\t in group %d ..." % groupInd)
             currentGroup = oldGroup.addNewCovariateToGroup(covariateInd, groupInd)
             print("\t\t current group structure: %s " % (currentGroup.partition,))
             # print currentGroup.partition
             dataForOKGT, groupForOKGT = data.getGroupedData(currentGroup)
             print groupForOKGT.partition
             xkernels = [kernel] * groupForOKGT.size
             parametersForOKGT = Parameters(groupForOKGT, ykernel, xkernels)
             currentOKGT = OKGTReg(dataForOKGT, parametersForOKGT)
             # res = currentOKGT.train_Vanilla()
             res = currentOKGT.train_Nystroem(10)
             currentR2 = res['r2']
             if currentR2 > bestR2:
                 print("\t\t current R2 =\t %.10f \t *" % currentR2)
                 bestR2 = currentR2
                 bestOKGT = currentOKGT
                 bestCovariateIndex = covariateInd