def profile_cwpath_robust_graphnet(): # get training data and constants Data = np.load("Data.npz") X = Data['X'][0:1000,:] print "Data matrix size:",X.shape Y = Data['Y'][0:1000] nx = np.sqrt(X.shape[1]) ny = np.sqrt(X.shape[1]) A = construct_adjacency_list(nx,ny,1) lam_max = get_lambda_max(X,Y) tol = 1e-6 initial=None # choose penalty grid l1 = np.linspace(4*lam_max, 0.2*lam_max, num=100) l2 = 100. l3 = 1000. delta = 1.0 # setup problem problemtype = graphnet.RobustGraphNet problemkey = 'RobustGraphNet' print "Robust GraphNet with penalties (l1, l2, l3, delta)", l1, l2, l3, delta l = cwpath.CoordWise((X, Y, A), problemtype, initial_coefs=initial) #,initial_coefs=np.array([14.]*10)) l.problem.assign_penalty(path_key='l1',l1=l1,l2=l2,l3=l3,delta=delta) coefficients, residuals = l.fit(tol=tol, initial=initial)
def profile_cwpath_robust_graphnet(): # get training data and constants Data = np.load("Data.npz") X = Data["X"][0:1000, :] print "Data matrix size:", X.shape Y = Data["Y"][0:1000] nx = np.sqrt(X.shape[1]) ny = np.sqrt(X.shape[1]) A = construct_adjacency_list(nx, ny, 1) lam_max = get_lambda_max(X, Y) tol = 1e-6 initial = None # choose penalty grid l1 = np.linspace(4 * lam_max, 0.2 * lam_max, num=100) l2 = 100.0 l3 = 1000.0 delta = 1.0 # setup problem problemtype = graphnet.RobustGraphNet problemkey = "RobustGraphNet" print "Robust GraphNet with penalties (l1, l2, l3, delta)", l1, l2, l3, delta l = cwpath.CoordWise((X, Y, A), problemtype, initial_coefs=initial) # ,initial_coefs=np.array([14.]*10)) l.problem.assign_penalty(path_key="l1", l1=l1, l2=l2, l3=l3, delta=delta) coefficients, residuals = l.fit(tol=tol, initial=initial)
def profile_test_graphnet(): # get training data and constants Data = np.load("Data.npz") X = Data['X'][0:1000,:] Y = Data['Y'][0:1000] G = None lam_max = get_lambda_max(X,Y) cwpathtol = 1e-6 # penalty grid values l1vec = np.linspace(0.95*lam_max, 0.0001*lam_max, num=100).tolist() results, problemkey = test_graphnet(X, Y, G, l1vec, 1e4, 1e6, 0.1, -999.0,initial=None,tol=cwpathtol,scipy_compare=False)
def profile_test_graphnet(): # get training data and constants Data = np.load("Data.npz") X = Data["X"][0:1000, :] Y = Data["Y"][0:1000] G = None lam_max = get_lambda_max(X, Y) cwpathtol = 1e-6 # penalty grid values l1vec = np.linspace(0.95 * lam_max, 0.0001 * lam_max, num=100).tolist() results, problemkey = test_graphnet( X, Y, G, l1vec, 1e4, 1e6, 0.1, -999.0, initial=None, tol=cwpathtol, scipy_compare=False )