0
$\begingroup$

I am new to ML and python. I am facing an issue related to the training SVM model. I have a training data file size (200,50,120). Where 200 are my examples (or experiments). While Actual data is a matrix X= 50x120. Here 120 are features and 50 is the sample size. On the other side, there is a Y=labels file with size (200,1). I am confused, how to train the model with a matrix? I read some comments about flattering the features into an array. whats is its purpose?

$\endgroup$
2
  • $\begingroup$ so what are the 50 "samples"? Time series? $\endgroup$ Apr 27, 2020 at 21:11
  • $\begingroup$ What does "flattering the features" mean? Flattening perhaps? But then...flatten to put the features into an array? What for? What about using matrix algebra for matrices? $\endgroup$
    – Carl
    May 2, 2020 at 3:50

2 Answers 2

0
$\begingroup$

Considering your case, the input to an SVM model (assuming you are using scikit-learn) is a 2D array with a shape of (n_samples, n_features). Now given the dimensions of your data, think about how it can be brought to this form so that the fit method from sklearn.svm.SVC can be used directly. The quickest idea that comes to the mind is to somehow change the dimension of the matrix (50x120) because we already have 200 as the number of samples. The way it is done in machine learning is the data is "flattened" such that it can be represented by a vector. Another interesting way to think about this is when you vectorize your data, you are essentially representing it by a point in that dimensional space (that is, in 50x120-dimensional space, each example becomes a point). So, with the help of "flattening", the input to the model is nothing but 200 data points, each in 50x120-dimensional space.

Here are some quick references for training an SVM model:

1) Scikit-SVM

2) SVM code examples

$\endgroup$
1
$\begingroup$

The purpose of flattening (or reshaping in general) is to match dimensions of data and model layer to enable training.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.