def cv_train(self, X, Y, regMin=1e-30, regMax=1e+30, K=100):
     patience = 100
     regMinStart = regMin
     regMaxStart = regMax
     BETAs = []
     time_start = time.time()
     time_diffs = []
     minFactor = 1
     maxFactor = 1
     if self.realDataFlag:
         minFactor = 0.75
         maxFactor = 1.25
     for clf in [Lasso()]:  #, MCP(), SCAD()]:
         betaM = None
         regMin = regMinStart
         regMax = regMaxStart
         iteration = 0
         while regMin < regMax and iteration < patience:
             iteration += 1
             reg = np.exp((np.log(regMin) + np.log(regMax)) / 2.0)
             # print("Iter:{}\tlambda:{}".format(iteration, lmbd), end="\t")
             clf.setLambda(reg)
             clf.setLearningRate(self.learningRate)
             clf.fit(X, Y)
             beta = clf.getBeta()
             k = len(np.where(beta != 0)[0])
             if k < minFactor * K:  # Regularizer too strong
                 regMax = reg
                 if betaM is None:
                     betaM = beta
             elif k > maxFactor * K:  # Regularizer too weak
                 regMin = reg
                 betaM = beta
             else:
                 betaM = beta
                 break
         BETAs.append(
             np.abs(betaM)
         )  # make sure this is absolute value for evaluation ROC curve
         time_diffs.append(time.time() - time_start)
         time_start = time.time()
     return BETAs, time_diffs
 def train_lasso(self, X, y):  #, mu):
     lasso = Lasso()
     lasso.fit(X, y)
     return lasso.getBeta()