# initializing the Frovedis server argvs = sys.argv argc = len(argvs) if (argc < 2): print 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")' quit() FrovedisServer.initialize(argvs[1]) mat = pd.read_csv("./input/train_1.csv") lbl = np.array([1, 0, 0, 1], dtype=np.float64) lbl1 = np.array([0.2, 0.3, 0.8, 0.6]) c_temp = 0 r_temp = 0 # fitting input matrix and label on DecisionTree Classifier object dtc1 = DecisionTreeClassifier() try: dtc = dtc1.fit(mat, lbl) except TypeError, e: c_temp = 1 # fitting input matrix and label on DecisionTree Regressor object dtr1 = DecisionTreeRegressor() try: dtr = dtr1.fit(mat, lbl1) except TypeError, e: r_temp = 1 if c_temp == 1 and r_temp == 1: print("Status : Passed") else:
argc = len(argvs) if (argc < 2): print 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")' quit() FrovedisServer.initialize(argvs[1]) mat = np.asmatrix([[1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]],dtype=np.float64) lbl = np.array([0.0, 1.0, 1.0, 0.0],dtype=np.float64) # fitting input matrix and label on DecisionTree Classifier object dtc1 = DecisionTreeClassifier(criterion='gini', splitter='best', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=1, min_impurity_decrease=0.0, class_weight=None, presort=False, verbose = 0) dtc = dtc1.fit(mat,lbl) dtc.debug_print() # predicting on train model print("predicting on DecisionTree classifier model: ") dtcm = dtc.predict(mat[2:3]) print dtcm print("Accuracy score for predicted DecisionTree Classifier model") print dtc.score(mat,lbl) # fitting input matrix and label on DecisionTree Regressor object dtr1 = DecisionTreeRegressor(criterion='mse', splitter='best',
# initializing the Frovedis server argvs = sys.argv argc = len(argvs) if (argc < 2): print 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")' quit() FrovedisServer.initialize(argvs[1]) mat = pd.DataFrame([[1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]]) lbl = np.array([0.0, 1.0, 1.0, 0.0]) # fitting input matrix and label on DecisionTree Classifier object dtc1 = DecisionTreeClassifier(max_depth=None) dtc = dtc1.fit(mat, lbl) dtc.debug_print() # predicting on train model print("predicting on DecisionTree classifier model: ") dtcm = dtc.predict(mat) print dtcm print("Accuracy score for predicted DecisionTree Classifier model") print dtc.score(mat, lbl) # fitting input matrix and label on DecisionTree Regressor object dtr1 = DecisionTreeRegressor(max_depth=None) lbl1 = np.array([1.2, 0.3, 1.1, 1.9]) dtr = dtr1.fit(mat, lbl1) dtr.debug_print()
if (argc < 2): print 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")' quit() FrovedisServer.initialize(argvs[1]) mat = pd.DataFrame([[1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]]) lbl = np.array([0.0, 1.0, 1.0, 0.0]) lbl1 = np.array([0.2,0.1,0.8,0.6]) c_temp = 0 r_temp = 0 # fitting input matrix and label on DecisionTree Classifier object dtc1 = DecisionTreeClassifier(min_samples_leaf=-1) try: dtc = dtc1.fit(mat,lbl) except ValueError, e: c_temp = 1 # fitting input matrix and label on DecisionTree Regressor object dtr1 = DecisionTreeRegressor(min_samples_leaf=-1) try: dtr = dtr1.fit(mat,lbl1) except ValueError, e: r_temp = 1 if c_temp == 1 and r_temp == 1: print("Status : Passed")
argc = len(argvs) if (argc < 2): print( 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")' ) quit() from frovedis.exrpc.server import FrovedisServer FrovedisServer.initialize(argvs[1]) # classification data from sklearn.datasets import load_breast_cancer mat, lbl = load_breast_cancer(return_X_y=True) # fitting input matrix and label on DecisionTree Classifier object dtc = DecisionTreeClassifier(criterion='gini', max_depth=5) dtc.fit(mat, lbl) #dtc.debug_print() # predicting on train model print("predicting on DecisionTree classifier model: ") print(dtc.predict(mat)) print("predicting probability on DecisionTree classifier model: ") print(dtc.predict_proba(mat)) print("prediction accuracy: %.4f" % (dtc.score(mat, lbl))) # regression data from sklearn.datasets import load_boston mat, lbl = load_boston(return_X_y=True) # fitting input matrix and label on DecisionTree Regressor object
if (argc < 2): print 'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")' quit() FrovedisServer.initialize(argvs[1]) mat = pd.DataFrame([[1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]]) lbl = np.array([0.0, 1.0, 1.0, 0.0]) lbl1 = np.array([0.2,0.1,0.8,0.6]) c_temp = 0 r_temp = 0 # fitting input matrix and label on DecisionTree Classifier object dtc1 = DecisionTreeClassifier(criterion='mse') try: dtc = dtc1.fit(mat,lbl) except ValueError, e: c_temp = 1 # fitting input matrix and label on DecisionTree Regressor object dtr1 = DecisionTreeRegressor(criterion='gini') try: dtr = dtr1.fit(mat,lbl1) except ValueError, e: r_temp = 1 if c_temp == 1 and r_temp == 1: print("Status : Passed")