Skip to content

Instantly share code, notes, and snippets.

@siddharthganjoo
Created August 23, 2021 07:17
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 siddharthganjoo/306a60c9775cb08bafc3e0e3adaf01c0 to your computer and use it in GitHub Desktop.
Save siddharthganjoo/306a60c9775cb08bafc3e0e3adaf01c0 to your computer and use it in GitHub Desktop.
#train test split
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.3,stratify=y, random_state = 42)
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
x_train = sc.fit_transform(x_train)
x_test = sc.transform(x_test)
# convert the data to categorical labels
from tensorflow.keras.utils import to_categorical
y_train = to_categorical(y_train, num_classes=None)
y_test = to_categorical(y_test, num_classes=None)
print (y_train.shape)
#printing the shape of train data
x_train.shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment