UFO ET IT

지원 벡터의 수와 훈련 데이터 및 분류기 성능 간의 관계는 무엇입니까?

ufoet 2020. 11. 9. 21:39
반응형

지원 벡터의 수와 훈련 데이터 및 분류기 성능 간의 관계는 무엇입니까?


일부 문서를 분류하기 위해 LibSVM을 사용하고 있습니다. 최종 결과가 보여 주듯이 문서는 분류하기가 조금 어려운 것 같습니다. 그러나 모델을 훈련하는 동안 뭔가를 발견했습니다. 즉, 내 트레이닝 세트가 예를 들어 1000이면 약 800 개가 지원 벡터로 선택됩니다. 나는 이것이 좋은 것인지 나쁜 것인지 찾기 위해 모든 곳을 찾았습니다. 지원 벡터의 수와 분류기 성능간에 관계가 있습니까? 나는이 포스트 이전 포스트를 읽었다 . 그러나 매개 변수 선택을 수행하고 있으며 특징 벡터의 속성이 모두 정렬되어 있음을 확신합니다. 관계를 알면됩니다. 감사. 추신 : 선형 커널을 사용합니다.


서포트 벡터 머신은 최적화 문제입니다. 그들은 가장 큰 여백으로 두 클래스를 나누는 초평면을 찾으려고합니다. 지지 벡터는이 여백 내에있는 점입니다. 단순한 것에서 더 복잡한 것까지 구축하면 이해하기 가장 쉽습니다.

하드 마진 선형 SVM

데이터가 선형으로 분리 될 수 있고 하드 마진을 사용하는 훈련 세트 (슬랙 허용 안 됨)에서 지원 벡터는 지원 하이퍼 플레인을 따라 놓인 점입니다 (초평면의 가장자리에서 분할 하이퍼 플레인에 평행 한 하이퍼 플레인). 여유)

하드 마진 SVM

모든지지 벡터는 정확히 여백에 있습니다. 데이터 세트의 차원 수나 크기에 관계없이 지원 벡터의 수는 2 개에 불과할 수 있습니다.

소프트 마진 선형 SVM

하지만 데이터 세트가 선형 적으로 분리되지 않으면 어떻게 될까요? 소프트 마진 SVM을 소개합니다. 우리는 더 이상 데이터 포인트가 여백 밖에있을 필요가 없으며 일부 데이터 포인트가 선을 넘어 여백으로 이탈 할 수 있습니다. 이를 제어하기 위해 slack 매개 변수 C를 사용합니다. (nu-SVM의 nu) 이것은 우리에게 훈련 데이터 세트에서 더 넓은 마진과 더 큰 오류를 제공하지만 일반화를 개선하고 선형 적으로 분리 할 수없는 데이터의 선형 분리를 찾을 수있게합니다.

소프트 마진 선형 SVM

이제 지원 벡터의 수는 허용되는 여유와 데이터 분포에 따라 다릅니다. 많은 양의 여유를 허용하면 많은 지원 벡터를 갖게됩니다. 여유를 거의 허용하지 않으면 지원 벡터가 거의 없습니다. 정확도는 분석중인 데이터에 적합한 여유 수준을 찾는 데 달려 있습니다. 일부 데이터는 높은 수준의 정확도를 얻을 수 없으며 가능한 한 가장 적합한 것을 찾아야합니다.

비선형 SVM

이것은 비선형 SVM으로 이어집니다. 우리는 여전히 데이터를 선형 적으로 나누려고 노력하고 있지만 이제는 더 높은 차원의 공간에서이를 수행하려고합니다. 이것은 물론 자체 매개 변수 세트가있는 커널 함수를 통해 수행됩니다. 이것을 원래의 특성 공간으로 다시 변환하면 결과는 비선형입니다.

여기에 이미지 설명 입력

Now, the number of support vectors still depends on how much slack we allow, but it also depends on the complexity of our model. Each twist and turn in the final model in our input space requires one or more support vectors to define. Ultimately, the output of an SVM is the support vectors and an alpha, which in essence is defining how much influence that specific support vector has on the final decision.

Here, accuracy depends on the trade-off between a high-complexity model which may over-fit the data and a large-margin which will incorrectly classify some of the training data in the interest of better generalization. The number of support vectors can range from very few to every single data point if you completely over-fit your data. This tradeoff is controlled via C and through the choice of kernel and kernel parameters.

I assume when you said performance you were referring to accuracy, but I thought I would also speak to performance in terms of computational complexity. In order to test a data point using an SVM model, you need to compute the dot product of each support vector with the test point. Therefore the computational complexity of the model is linear in the number of support vectors. Fewer support vectors means faster classification of test points.

A good resource: A Tutorial on Support Vector Machines for Pattern Recognition


800 out of 1000 basically tells you that the SVM needs to use almost every single training sample to encode the training set. That basically tells you that there isn't much regularity in your data.

Sounds like you have major issues with not enough training data. Also, maybe think about some specific features that separate this data better.


Both number of samples and number of attributes may influence the number of support vectors, making model more complex. I believe you use words or even ngrams as attributes, so there are quite many of them, and natural language models are very complex themselves. So, 800 support vectors of 1000 samples seem to be ok. (Also pay attention to @karenu's comments about C/nu parameters that also have large effect on SVs number).

To get intuition about this recall SVM main idea. SVM works in a multidimensional feature space and tries to find hyperplane that separates all given samples. If you have a lot of samples and only 2 features (2 dimensions), the data and hyperplane may look like this:

여기에 이미지 설명 입력

Here there are only 3 support vectors, all the others are behind them and thus don't play any role. Note, that these support vectors are defined by only 2 coordinates.

Now imagine that you have 3 dimensional space and thus support vectors are defined by 3 coordinates.

여기에 이미지 설명 입력

This means that there's one more parameter (coordinate) to be adjusted, and this adjustment may need more samples to find optimal hyperplane. In other words, in worst case SVM finds only 1 hyperplane coordinate per sample.

When the data is well-structured (i.e. holds patterns quite well) only several support vectors may be needed - all the others will stay behind those. But text is very, very bad structured data. SVM does its best, trying to fit sample as well as possible, and thus takes as support vectors even more samples than drops. With increasing number of samples this "anomaly" is reduced (more insignificant samples appear), but absolute number of support vectors stays very high.


SVM classification is linear in the number of support vectors (SVs). The number of SVs is in the worst case equal to the number of training samples, so 800/1000 is not yet the worst case, but it's still pretty bad.

Then again, 1000 training documents is a small training set. You should check what happens when you scale up to 10000s or more documents. If things don't improve, consider using linear SVMs, trained with LibLinear, for document classification; those scale up much better (model size and classification time are linear in the number of features and independent of the number of training samples).


소스간에 약간의 혼동이 있습니다. 예를 들어 교과서 ISLR 6th Ed에서 C는 "경계 위반 예산"으로 설명되며, C가 높을수록 더 많은 경계 위반과 더 많은 지원 벡터가 허용됩니다. 그러나 R과 python의 svm 구현에서 매개 변수 C는 반대 인 "위반 패널티"로 구현됩니다. 그러면 C 값이 높을수록 지원 벡터가 더 적다는 것을 알 수 있습니다.

참고 URL : https://stackoverflow.com/questions/9480605/what-is-the-relation-between-the-number-of-support-vectors-and-training-data-and

반응형