# How to train model when Data is consist of matrices [closed]

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?

• so what are the 50 "samples"? Time series? Apr 27, 2020 at 21:11
• 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?
– Carl
May 2, 2020 at 3:50

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.