Skip to content

Instantly share code, notes, and snippets.

@zero731
Created March 11, 2021 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zero731/40d0c2b6be401293cdcd5412bd484bee to your computer and use it in GitHub Desktop.
Save zero731/40d0c2b6be401293cdcd5412bd484bee to your computer and use it in GitHub Desktop.
train-test split for example churn analysis
## Read in dataset from csv file
model_data = pd.read_csv('Data/model_data.csv')
## Define target variable
target = 'Churn'
## Separate features (X) and target (y) for train-test split
X = model_data.drop(columns=[target], axis=1).copy()
y = model_data[target].copy()
## Define random seed to use for train-test-split and
## classifiers for reproducibility
random_seed = 319
## Split the data into training and test sets prior to preprocessing
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.25,
random_state=random_seed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment