0

I would like to ask for help. I have a dataset which has a column called pixels (I loaded with Pandas):

enter image description here

I would like to train this image classification dataset. So, I used split function inside apply pandas function

dfemotrain['pic']=dfemotrain['pixels'].apply(lambda x: np.array(x.split()).reshape(48, 48))

Later on, I used train_test_split from sklearn

X = dfemotrain['pic'].values
y = dfemotrain['emotion'].values
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.25, stratify=y, random_state=42)
print(X_train.shape, X_val.shape, y_train.shape, y_val.shape)

I got (21750,) (7250,) (21750,) (7250,) and I am not sure how to convert to a numpy array n_samplesx48x48 to input to a Deep Learning model

enter image description here

Please any suggestion to solve this issue. Thanks in advance

5
  • I believe you want to use reshape stackoverflow.com/questions/12575421/… Commented Mar 23, 2023 at 21:23
  • 1
    X = np.array(dfemotrain['pic'].astype('int').to_list()) Commented Mar 23, 2023 at 21:33
  • 1
    np.array(x.split(),dtype=int) should turn those cell values into numeric arrays. What did you load this from? From a csv? The frame cells contain strings, not lists or arrays. Did you create the source file yourself, or get it from someone else? Commented Mar 23, 2023 at 21:45
  • I believe this question is not related to scikit-learn or tensorflow, therefore the tags are removed. Please try not to use irrelevant tags. Commented Mar 24, 2023 at 0:32
  • don't you have a data sample ? Commented Mar 24, 2023 at 2:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.