print("\t\t\t OPTION 2: using CART to forecast REGRESSION.") print("\t\t\t OPTION x: exit.") c = input("\n\t\t\t Please input your option:") if c == '1': print("\t\t STEP1: Load dataset...") xx, yy = ds.load(True, r'.\dataset.dat') xx = ds.discrete_vec(xx, K=DS.DATAUtil.g_SuperParam['K']) y_c = yy[:, 1] xx_t, y_t = ds.load(True, r'.\testds.dat') x_t = ds.discrete_vec(xx_t, K=DS.DATAUtil.g_SuperParam['K']) y_t_c = y_t[:, 1] print("\t\t STEP2: Build CART Tree...") model = DecisionTree.CART(c_r=True) model.train(xx, y_c) print("\t\t STEP3: Display CART Tree...") PlotUtil.init_Plot("CART Decision Tree - (C)") model.display_Tree() PlotUtil.show_Plot() print("\t\t STEP4: Predict by CART Tree...") y_p = model.predict(x_t) y_p = y_p.flatten() if y_p.shape[0] > 0: eval_y = np.zeros_like(y_p, dtype=int) eval_y = np.where((y_p == y_t_c), 1, 0) y_p = ds.y_int2str(y_p) y_p = np.reshape(y_p, (-1, 1)) print("The predict result is:")