I'm running a SVM sentiment analysis project and I wanted to vectorize it using tf-idf. the code snip for the tf-idf section is below:
X = table_tfidf
y = df['label']
random_state = 42
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_text = train_test_split(X, y, test_size=0.2, random_state=random_state)
#dividing training data to train data and validation data
X_train_train, X_train_val, y_train_train, y_train_val = train_test_split(X_train, y_train, test_size = 0.2)
how do I export the X_train and the y_train only data into a .csv file? I wanted to check if the data were properly split. Thank you!
This should do it:
X_train.to_csv('X_train.csv')