svm

One class SVM probability estimates and what is the different between one class SVM and clustering

一世执手 提交于 2020-01-02 09:53:58
问题 I have a set of images. I would like to learn a one class SVM (OC-SVM) to model the distribution of a particular class (positive) as I dont have enough examples to represent the other classes (negative). What I understood about OC-SVM is that it tries to separate the data from the origin or in other words it tries to learn a hyper sphere to fit the one class data. My questions are, If I want to use the output of the OC-SVM as a probability estimate, how can I do it? What is the difference

Import trained SVM from scikit-learn to OpenCV

对着背影说爱祢 提交于 2020-01-02 04:58:05
问题 I'm porting an algorithm that uses a Support Vector Machine from Python (using scikit-learn) to C++ (using the machine learning library of OpenCV). I have access to the trained SVM in Python, and I can import SVM model parameters from an XML file into OpenCV. Since the SVM implementation of both scikit-learn and OpenCV is based on LibSVM, I think it should be possible to use the parameters of the trained scikit SVM in OpenCV. The example below shows an XML file which can be used to initialize

How to fix the false positives rate of a linear SVM?

柔情痞子 提交于 2020-01-01 09:12:21
问题 I am an SVM newbie and this is my use case: I have a lot of unbalanced data to be binary classified using a linear SVM. I need to fix the false positives rate at certain values and measure the corresponding false negatives for each value. I am using something like the following code making use of scikit-learn svm implementation: # define training data X = [[0, 0], [1, 1]] y = [0, 1] # define and train the SVM clf = svm.LinearSVC(C=0.01, class_weight='auto') #auto for unbalanced distributions

Plot hyperplane Linear SVM python

﹥>﹥吖頭↗ 提交于 2020-01-01 03:45:06
问题 I am trying to plot the hyperplane for the model I trained with LinearSVC and sklearn. Note that I am working with natural languages; before fitting the model I extracted features with CountVectorizer and TfidfTransformer. Here the classifier: from sklearn.svm import LinearSVC from sklearn import svm clf = LinearSVC(C=0.2).fit(X_train_tf, y_train) Then I tried to plot as suggested on the Scikit-learn website: # get the separating hyperplane w = clf.coef_[0] a = -w[0] / w[1] xx = np.linspace(

Which decision_function_shape for sklearn.svm.SVC when using OneVsRestClassifier?

拈花ヽ惹草 提交于 2020-01-01 03:33:11
问题 I am doing multi-label classification where I am trying to predict correct tags to questions: (X = questions, y = list of tags for each question from X). I am wondering, which decision_function_shape for sklearn.svm.SVC should be be used with OneVsRestClassifier? From docs we can read that decision_function_shape can have two values 'ovo' and 'ovr' : decision_function_shape : ‘ovo’, ‘ovr’ or None, default=None Whether to return a one-vs-rest (‘ovr’) decision function of shape (n_samples, n

libsvm Shrinking Heuristics

痞子三分冷 提交于 2020-01-01 01:53:09
问题 I'm using libsvm in C-SVC mode with a polynomial kernel of degree 2 and I'm required to train multiple SVMs. During training, I am getting either one or even both of these warnings for some of the SVMs that I train: WARNING: using -h 0 may be faster * WARNING: reaching max number of iterations optimization finished, #iter = 10000000 I've found the description for the h parameter: -h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1) and I've tried to read the explanation

Python : How to find Accuracy Result in SVM Text Classifier Algorithm for Multilabel Class

心已入冬 提交于 2019-12-31 22:26:29
问题 I have used following set of code: And I need to check accuracy of X_train and X_test The following code works for me in my classification problem over multi-labeled class import numpy as np from sklearn.pipeline import Pipeline from sklearn.feature_extraction.text import CountVectorizer from sklearn.svm import LinearSVC from sklearn.feature_extraction.text import TfidfTransformer from sklearn.multiclass import OneVsRestClassifier X_train = np.array(["new york is a hell of a town", "new york

libsvm java implementation

不打扰是莪最后的温柔 提交于 2019-12-31 08:48:14
问题 I am trying to use the java bindings for libsvm: http://www.csie.ntu.edu.tw/~cjlin/libsvm/ I have implemented a 'trivial' example which is easily linearly separable in y. The data is defined as: double[][] train = new double[1000][]; double[][] test = new double[10][]; for (int i = 0; i < train.length; i++){ if (i+1 > (train.length/2)){ // 50% positive double[] vals = {1,0,i+i}; train[i] = vals; } else { double[] vals = {0,0,i-i-i-2}; // 50% negative train[i] = vals; } } Where the first

Normalizing feature values for SVM

萝らか妹 提交于 2019-12-30 18:26:13
问题 I've been playing with some SVM implementations and I am wondering - what is the best way to normalize feature values to fit into one range? (from 0 to 1) Let's suppose I have 3 features with values in ranges of: 3 - 5. 0.02 - 0.05 10-15. How do I convert all of those values into range of [0,1]? What If, during training, the highest value of feature number 1 that I will encounter is 5 and after I begin to use my model on much bigger datasets, I will stumble upon values as high as 7? Then in

Normalizing feature values for SVM

随声附和 提交于 2019-12-30 18:26:09
问题 I've been playing with some SVM implementations and I am wondering - what is the best way to normalize feature values to fit into one range? (from 0 to 1) Let's suppose I have 3 features with values in ranges of: 3 - 5. 0.02 - 0.05 10-15. How do I convert all of those values into range of [0,1]? What If, during training, the highest value of feature number 1 that I will encounter is 5 and after I begin to use my model on much bigger datasets, I will stumble upon values as high as 7? Then in