-
Notifications
You must be signed in to change notification settings - Fork 2k
Multiclass SVM and DTW System.AggregateException #470
Comments
for (int i = 0; i <= Sequences.Count; i++)
… On Mar 4, 2017, at 4:33 AM, vutle ***@***.***> wrote:
for (int i = 0; i < Sequences.Count; i++)
|
Hi mmehrle, |
Hi cesarouza, Where j = sharedVectors[i] is greater than lock.Length (e.g. j = 66 when locks.Length = 36. |
Hello there, Well, first of all, sorry for the super long delay in replying. I couldn't answer the issue at the time and I couldn't manage to get back into it under a reasonable amount of time... Second, many thanks for reporting the issue! Indeed, this issue happened due to a problem with the function evaluation cache of the MulticlassSupportVectorMachine. I will be committing a fix in a few minutes. Here is a slightly simplified version of the code above (but without the Preprocessing part), that I had added as a unit test to the framework, and that can serve as an example in case others would be interested in using the DynamicTimeWarping kernel and are looking for ideas:
Regards, |
Hi cesarsouza, Looking at the example that you post it, the Accord library has a function to read data from a CSV file. Regards, |
Hi Vinícius, Resources.Shapes is just the name of a variable that contained the .csv file as single string. Something like string shapes = "col1, col2, col3\na,b,c\n,d,e,f"; If you would like to read from a file, just use the class constructor instead: var reader = new CsvReader(path_to_your_csv_file_in_your_hd, hasHeaders: true); Hope it helps! Regards, |
Hi Cesar, Thanks. My csv file is similar to the shapes.csv file with addition of one more column and I would like to organize it as you commented in the last post: Regards, |
Hi Cesar, I have just figured it out. |
Hmmm... Linq can be daunting some times. If you are in doubt, just write it using plain for/foreach loops. However, in your case, I think you can still use Zip if you Zip the columns two by two. Something like Enumerable.Zip(Enumerable.Zip(g.Select(x => x.X), g.Select(x => x.Y)), g.Select(x=> x.Z)) But as I said, just write it using plain for loops. Linq is supposed to help with the readability (not with speed). So if it isn't helping with the readability for you, there is very little use in using it in the first place. |
Hi Cesar, Thanks for the replay. Finally, what namespace that I have to add for using this: Regards, |
The Assert command comes from NUnit (the example was posted from inside a NUnit unit test). You do not need to use it in your application. Rather, just compare the contents of the You can compute the error between those two by using the ConfusionMatrix, for example: var cm = new ConfusionMatrix(expected: output, predicted: predicted);
double error = cm.Accuracy; // should be a value between 0 and 1 where 1 means everything got classified perfectly Hope it helps, |
Hi Cesar, It helped thanks. Regards, |
Hi Vinicius, Well, actually that is a bit surprising that the Gaussian kernel worked since its very probable that you have sequences with a variable number of observations. It should have thrown an exception in this case. What is the average length of your sequences? Do different sequences have different lengths in the problem you are trying to solve? Regards, |
Hi Cesar, All my sequences has 30 samples each. They all have the same size. I did that on purpose in order to test with other kernels (to not get that exception). Regards, |
Thanks cesarouza, there is no more error. |
Hi Vinicius, If all your sequences have the same length it implies that you have already aligned them somehow. And if they are already aligned, then maybe there is no need to use Dynamic Time Warping and a standard kernel could also work as good or better than DTW. Yes, Accord has methods for doing cross-validation, but the way it behaves depends on how you use them. If you do it in a way similar to this example and use K as 10, then it should create 10 SVMs on different partitions of your dataset and output the average classification error. However, please note that k-fold cross validation should not be used to select the best model with the smallest error, at all. Instead, it should be used to help you determine which are the best parameters for your model, so that you can draw conclusions about the model performance without being bogged with fears that the performance you are seeing are actually due to a bias in the dataset rather than your choice of model / hyperparameters of your model. I am not completely sure if that is what you did, but you should never "pick" one of the models trained on one of the folds in cross-validation. Rather, you should only consider the mean error to determine which hyperparameters you should use when training your final model in your entire dataset. Regards, |
Hi Cesar, Yes. I followed your example on cross validation and I only used it as a validation method for tuning parameters, as you recommended. Regards, |
Fixed in release 3.6.0. |
Hi cesarouza,
I tried to use multiclass SVM with DTW with the following code but have the following error:
The code I used is given below. The data for the sequences is attached.
The data Shapes.csv contains (SequenceID,ClassID,ClassName,X,Y). There are only 3 classes (Circle, Triangle and Rectangle) with lots of sequences.
The code works fine when I have a few sequences. If I have this many sequences, I get that described error.
Do you know what is causing this?
Shapes.zip
The text was updated successfully, but these errors were encountered: