コード例 #1
0
ファイル: main_b_iv_c.py プロジェクト: tongzhang888/DSCI_552
__author__ = 'Aaron Yang'
__email__ = '*****@*****.**'
__date__ = '11/6/2019 8:52 AM'

import numpy as np
from sklearn.exceptions import ConvergenceWarning
from sklearn.preprocessing import LabelEncoder, MinMaxScaler
from sklearn.metrics import precision_recall_fscore_support as score
from ay_hw_6._global import ROOT_PATH, WDBC_FILE_PATH, SPLASH, M
from ay_hw_6.util_data import load_data, train_test_split_by_class_and_ratio

if __name__ == "__main__":

	simplefilter(action='ignore', category=ConvergenceWarning)
	X_data, y_data = load_data(ROOT_PATH + SPLASH + WDBC_FILE_PATH)
	X_data = MinMaxScaler().fit(X_data).transform(X_data)
	labelEncoder = LabelEncoder().fit(['B', 'M'])
	y_data = labelEncoder.transform(y_data)

	accuracyList = list()
	precisionList = list()
	recallRateList = list()
	f_scoreList = list()
	aucList = list()
	y_test_predict = None
	y_test_true = None
	for i in tqdm(range(2)):
		X_train, X_test, y_train, y_test = train_test_split_by_class_and_ratio(X_data, y_data, test_size=0.2,
																			   random_state=i, pos_class=0,
																			   neg_class=1)
コード例 #2
0
ファイル: main_a.py プロジェクト: tongzhang888/DSCI_552
#

__author__ = 'Aaron Yang'
__email__ = '*****@*****.**'
__date__ = '11/5/2019 11:57 AM'

from ay_hw_6._global import ROOT_PATH, BANK_NOTE_FILE_PATH, SPLASH
from ay_hw_6.util_data import load_data, train_test_split_by_exact_number

if __name__ == "__main__":
    X_data, y_data = load_data(ROOT_PATH + SPLASH + BANK_NOTE_FILE_PATH,
                               X_startIndex=0,
                               X_endIndex=4,
                               y_index=-1)
    X_train, X_test, y_train, y_test = train_test_split_by_exact_number(
        X_data, y_data, test_size=472, random_state=2333)

    print("-----------\"Row Data\"-------------")
    print("the shape of X_data is: ", X_data.shape)
    print("the shape of y_data is: ", y_data.shape)
    print("-----------\"After Split\"-------------")
    print("the shape of X_train is: ", X_train.shape)
    print("the shape of X_test is: ", X_test.shape)
    print("the shape of y_train is: ", y_train.shape)
    print("the shape of y_test is: ", y_test.shape)