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

Frightera
  • 4,773
  • 2
  • 13
  • 28
GSandro_Strongs
  • 773
  • 3
  • 11
  • 24
  • I believe you want to use reshape https://stackoverflow.com/questions/12575421/convert-a-1d-array-to-a-2d-array-in-numpy – A Simple Programmer Mar 23 '23 at 21:23
  • 1
    `X = np.array(dfemotrain['pic'].astype('int').to_list())` – Quang Hoang Mar 23 '23 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? – hpaulj Mar 23 '23 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. – Frightera Mar 24 '23 at 00:32
  • don't you have a data sample ? – Laurent B. Mar 24 '23 at 02:38

0 Answers0