Created
March 11, 2021 00:25
-
-
Save zero731/40d0c2b6be401293cdcd5412bd484bee to your computer and use it in GitHub Desktop.
train-test split for example churn analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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