def randomSample(tupleData=None, testSize=0.2): print('=======================================================') print('=> Randoming data...') if (tupleData): X_train_names, X_test_names, y_train_name, y_test_name = \ train_test_split(np.asarray(tupleData[0]['X']), tupleData[0]['y'], test_size=testSize) X_train_address, X_test_address, y_train_address, y_test_address = \ train_test_split(np.asarray(tupleData[1]['X']), tupleData[1]['y'], test_size=testSize) X_train_phone, X_test_phone, y_train_phone, y_test_phone = \ train_test_split(np.asarray(tupleData[2]['X']), tupleData[2]['y'], test_size=testSize) else: datatuple = store.loadFeatureCSV() X_train_names, X_test_names, y_train_name, y_test_name = \ train_test_split(np.asarray(datatuple[0][1]), datatuple[0][0], test_size=testSize) X_train_address, X_test_address, y_train_address, y_test_address = \ train_test_split(np.asarray(datatuple[1][1]), datatuple[1][0], test_size=testSize) X_train_phone, X_test_phone, y_train_phone, y_test_phone = \ train_test_split(np.asarray(datatuple[2][1]), datatuple[2][0], test_size=testSize) X_train = np.append(np.append(X_train_names.tolist(), X_train_address.tolist(), axis=0), X_train_phone, axis=0) y_train = y_train_name + y_train_address + y_train_phone X_test = np.append(np.append(X_test_names.tolist(), X_test_address.tolist(), axis=0), X_test_phone, axis=0) y_test = y_test_name + y_test_address + y_test_phone print('=> Randomed data.') return (X_train, y_train, X_test, y_test)
def randomSample(tupleData=None, testSize=0.2): print('=======================================================') print('=> Randoming data...') if (tupleData): X_train_names, X_test_names, y_train_name, y_test_name = \ train_test_split(np.asarray(tupleData[0]['X']), tupleData[0]['y'], test_size=testSize) X_train_address, X_test_address, y_train_address, y_test_address = \ train_test_split(np.asarray(tupleData[1]['X']), tupleData[1]['y'], test_size=testSize) X_train_phone, X_test_phone, y_train_phone, y_test_phone = \ train_test_split(np.asarray(tupleData[2]['X']), tupleData[2]['y'], test_size=testSize) else: datatuple = store.loadFeatureCSV() X_train_names, X_test_names, y_train_name, y_test_name = \ train_test_split(np.asarray(datatuple[0][1]), datatuple[0][0], test_size=testSize) X_train_address, X_test_address, y_train_address, y_test_address = \ train_test_split(np.asarray(datatuple[1][1]), datatuple[1][0], test_size=testSize) X_train_phone, X_test_phone, y_train_phone, y_test_phone = \ train_test_split(np.asarray(datatuple[2][1]), datatuple[2][0], test_size=testSize) X_train = np.append(np.append(X_train_names.tolist(),X_train_address.tolist(), axis=0), X_train_phone, axis=0) y_train = y_train_name + y_train_address + y_train_phone X_test = np.append(np.append(X_test_names.tolist(), X_test_address.tolist(), axis=0), X_test_phone, axis=0) y_test = y_test_name + y_test_address + y_test_phone print('=> Randomed data.') return (X_train, y_train, X_test, y_test)