0

I'd like to use shape feature as a list in sklearn, is it possible? Using MLPClassifier

Given this input.

data=[{'forniture':1,'color':3, 'shape':[0.2,0.5,1.1]},
      {'forniture':2,'color':0, 'shape':[0.2,0.7,0.9]},
      {'forniture':2,'color':1, 'shape':[1.2,1.5,1.0]}]
pd.DataFrame(data)

Exit

   forniture  color            shape
0          1      3  [0.2, 0.5, 1.1]
1          2      0  [0.2, 0.7, 0.9]
2          2      1  [1.2, 1.5, 1.0]

When I pass shape as argument in clf.fit():
TypeError: float() argument must be a string or a number, not 'list'

But I need the entire list, because it is the shape, I can not convert to scalar like Volume.

Any recomendation to fit with the shape and not volume?

Thanks, I really appreciate your help.

1 Answers1

3

Upon reading the documentation here: https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html#sklearn.neural_network.MLPClassifier.fit It does not seem like it is possible to pass a list to the fit() function. Did you consider breaking up the list to three columns? If so it is explained here: Split a Pandas column of lists into multiple columns

Ofek Glick
  • 999
  • 2
  • 9
  • 20
  • Thanks. Yes, I was working with 3 diferent columns, but I thought it was going to be a good idea join them into a vector, list o matrix in order to improve the model. Because they are correlated data in real life. – Rulo Ramiro Aug 19 '21 at 13:02