1

I am trying to use data I collected from an experiment to create an SVM model using sci-kit. My input data is 3D array (example x below), with labels being boolean labels (example y).

X = [[[00, 00], [01, 01],[02,02]],[[10,10],[11,11],[12,12]],[[20,20],[21,21],[22,22]]]
y = [0, 1,1]
clf = svm.SVC()
clf.fit(X, y) 

However, whenever I try to execute the code above, I get the following error.

ValueError: Found array with dim 3. Estimator expected <= 2.

I am new to machine learning and scikit. I would appreciate any help and directions that help solve this problem.

Gocool
  • 13
  • 1
  • 3
  • This matrix `X` can never be defined in python. leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers – seralouk Mar 10 '20 at 16:10

1 Answers1

1

For computation purpose, the X must be a 2D matrix. For 3+ dimensions, it has to be a neural network such as Convolutionnal Neural Network or Recurrent Neural Network.

In your case, you should maybe flatten the last dimension leading to a 2D matrix such as:

X = [[00, 00, 01, 01, 02, 02],
     [10, 10, 11, 11, 12, 12],
     [20, 20, 21, 21, 22, 22]]

I'm saying maybe because this is really depending on what are your datas. If the 3rd dimension is time-related, you should consider using a Recurrent Neural Network. If it's something related to dynamic, you could compute the derivative for example. It's a case by case application and sometime the idea is not trivial

Nicolas M.
  • 1,472
  • 1
  • 13
  • 26