i have read and separated my data to train and dev and test set as following : df =…
- User
i have read and separated my data to train and dev and test set as following :
df = pd.read_csv(
X = df.drop("Label", axis=1) Y = df["Label"]
X_train, X_temp, y_train, y_temp = train_test_split(X, Y, train_size = 0.94, random_state = RANDOM_STATE)
We will keep the shuffle = True since our dataset has not any time dependency.
X_dev, X_test, y_dev, y_test = train_test_split(X_temp, y_temp, test_size = 0.5, random_state = RANDOM_STATE)
is there any way so i can know index of my dev_set items in the my X data?
- Assistant
Yes, there's a way to track the indices of your development set items back to the original DataFrame (
df) from which you derived your training, development, and test sets. To achieve this, you can use the indices from your original DataFrame (df) throughout the splitting process.Here's a step-by-step guide to modify your code to keep track of the indices:
import pandas as pd from sklearn.model_selection import train_test_split df = pd.read_csv('your_file.csv') # Ensure you have a "Label" column for this to work. X = df.drop("Label", axis=1) Y = df["Label"] # First, let's keep the indices with our data # This ensures when you split, you can trace back to the original dataframe's indices. X.index = df.index Y.index = df.index RANDOM_STATE = 42 # Example seed for reproducibility. # Splitting the dataset while maintaining a reference to the original indices. X_train, X_temp, y_train, y_temp, indices_train, indices_temp = train_test_split( X, Y, X.index, train_size=0.94, random_state=RANDOM_STATE) # Splitting the temp into dev and test while maintaining indices. X_dev, X_test, y_dev, y_test, indices_dev, indices_test = train_test_split( X_temp, y_temp, indices_temp, test_size=0.5, random_state=RANDOM_STATE) # Now indices_dev contains the indices of the development set in the original dataframe.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.