def autism_sets_process(): print( "---------------------Autism Adult Data Sets(CART)------------------------" ) autism_data_sets, autism_labels = utils.get_autism_data_set() autism_data_test_df, autism_data_train_df = utils.handle_data( autism_data_sets, autism_labels) autism_labels = array(autism_data_train_df.columns) # print(autism_labels) target_names = unique(autism_data_train_df.iloc[:, -1]) # print(target_names) dt = DecisionTree() fit_begin_time = datetime.datetime.now() print("Begin Time: " + str(fit_begin_time)) tree = dt.fit(autism_data_train_df) # print(tree) # print(autism_data_test_df) fit_end_time = datetime.datetime.now() print("End Time: " + str(fit_end_time)) print("Training used Time: " + str(fit_end_time - fit_begin_time)) autism_test_result_df = predict_data(dt, autism_data_test_df, autism_labels) report = utils.generate_report(autism_data_test_df, autism_test_result_df, target_names) print(report)
def healthy_sets_process(): print("---------------------Healthy Older People Sets(ID3)------------------------") healthy_data_sets, healthy_labels = utils.get_healthy_data_set() healthy_data_test_df, healthy_data_train_df = utils.handle_data(healthy_data_sets, healthy_labels) target_names = unique(healthy_data_train_df.iloc[:, -1]) # print(target_names) dt = DecisionTree() fit_begin_time = datetime.datetime.now() print("Begin Time: " + str(fit_begin_time)) tree = dt.fit(healthy_data_train_df) fit_end_time = datetime.datetime.now() print("End Time: " + str(fit_end_time)) print("Training used Time: " + str(fit_end_time - fit_begin_time)) healthy_test_result_df = predict_data(dt, healthy_data_test_df, healthy_labels) report = utils.generate_report(healthy_data_test_df, healthy_test_result_df, target_names) print(report)
def iris_sets_process(): print("---------------------Iris Data Sets(ID3)------------------------") iris_data_sets, iris_labels = utils.get_iris_data_set() iris_data_test_df, iris_data_train_df = utils.handle_data(iris_data_sets, iris_labels) target_names = unique(iris_data_train_df.iloc[:, -1]) # print(target_names) dt = DecisionTree() fit_begin_time = datetime.datetime.now() print("Begin Time: " + str(fit_begin_time)) tree = dt.fit(iris_data_train_df) fit_end_time = datetime.datetime.now() print("End Time: " + str(fit_end_time)) print("Training used Time: " + str(fit_end_time - fit_begin_time)) # print(tree) # print(iris_data_test_df) # r1 = dt.predict(["7.0", "3.2", "4.7", "1.4"]) # print(r1) iris_test_result_df = predict_data(dt, iris_data_test_df, iris_labels) # print(iris_test_result_df) report = utils.generate_report(iris_data_test_df, iris_test_result_df, target_names) print(report)