Skip to content

Instantly share code, notes, and snippets.

@VincentTatan
Created May 9, 2020 12:49
Show Gist options
  • Save VincentTatan/51257105b171ddff969079f4b313aedd to your computer and use it in GitHub Desktop.
Save VincentTatan/51257105b171ddff969079f4b313aedd to your computer and use it in GitHub Desktop.
def split_train_test (df, target_feature,test_size=0.2):
filtered_list = list(df._get_numeric_data().columns)
filtered_list.remove(target_feature)
X = df[filtered_list]
y = df[target_feature]
X_train, X_test, y_train,y_test= train_test_split(X,y,test_size=test_size)
print(''' X_train size : {}
y_train size : {}
X_test size : {}
y_test size : {}
'''.format( X_train.shape, X_test.shape, y_train.shape,y_test.shape))
return X_train, X_test, y_train,y_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment