svm

SVM in openCV throws “cv::Exception at memory location”

时间秒杀一切 提交于 2019-12-13 03:34:49
问题 I'm trying to create a simple OCR application with SVM, openCV, C++ and Visual Studio 2008 (mfc app). My training samples are binary images of machine-printed digits (0-9). I want to use DAGSVM for this multi-class problem. So I need to create 45 SVMs, each of which is the SVM of 2 class (SVM(0,1), SVM(0,2)... SVM(8,9)). Here's how things are going: SVM's parameters: CvSVMParams params; params.svm_type = CvSVM::C_SVC; params.kernel_type = CvSVM::LINEAR; params.term_crit = cvTermCriteria(CV

in self._compute_kernel(X) raise ValueError(“X.shape[0] should be equal to X.shape[1]”)

徘徊边缘 提交于 2019-12-13 03:32:19
问题 In my code in which X and y are the training data: from sklearn.svm import SVC clf = SVC(kernel=lambda x,y:gauss_kernel(x, y, 100) ) print(X.shape[0]) print(X.shape[1]) print(X.shape) clf.fit(X, y) I get the following error: 211 2 (211, 2) /Users/mona/anaconda/lib/python3.6/site-packages/sklearn/utils/validation.py:547: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel(). y = column_or_1d(y,

Set the weights of decision functions through stdin in Sklearn

北战南征 提交于 2019-12-13 02:54:36
问题 Is there a method that I can input the coefficients to the clf of SVC in my script, then apply clf.score() or clf.predict() function for further test? Currently I am using joblib.dump(clf,'file.plk') to save all the information of a trained clf . But this involves the disk writing/reading. It will be helpful for me if I can just define a clf with two arrays representing the support vector ( clf.support_vectors_ ), weights ( clf.coef_ / clf.dual_coef_ ), and bias ( clf.intercept_ )

SVM provided a bad result in my data. How to fix?

眉间皱痕 提交于 2019-12-13 01:50:26
问题 I have a dataset that contains 510 samples for training and 127 samples for testing, each sample has 7680 features. I want to design a model to predict the height (cm)-label-from the training data. Currently, I used SVM but it provided very bad result. Could you look at my code and give me some comments. You can try it in your machine using the dataset and a runnable code import numpy as np from sklearn.svm import SVR # Training Data train_X = np.loadtxt('trainX.txt') # 510 x 7680 train_Y =

Prefer one class in libsvm (python)

拜拜、爱过 提交于 2019-12-12 22:21:43
问题 I just started playing a bit with libsvm in python and got some simple classification to work. The problem is that I'm constructing a face detection system, and I want a very low false rejection rate . The svm on the other hand seems to optimize for equal false rejection and false acceptance. What options do I have here? And as a said earlier, I'm very new to libsvm, so be kind. ;) 回答1: SVMs are not usually thought of as a probabilistic model, but a maximally-discriminant model. Thus I have a

What does each item mean in svmLight Format

余生颓废 提交于 2019-12-12 20:52:22
问题 I am very confused about what each part means in a svmLight data format. For example: (label/target, [(feature, value), ...], queryid) Does the label means the rank of the data and queryid is the id of the object? For example: for the following item: 2 qid:1 1:4.000000 2:2.772589 3:0.266667 4:0.258154 5:37.330565 6:11.431241 7:37.307017 8:1.213630 9:21.342267 10:10.842279 11:15.634736 12:2.749495 13:-39.467448 14:-37.791635 15:-38.002289 16:14.000000 17:5.634790 18:0.063927 19:0.063290 20:28

query over grid.py

最后都变了- 提交于 2019-12-12 17:16:32
问题 Facing some problem with grid.py of libsvm. Tried implementing it, but gave syntax error. Typed: grid.py -svmtrain "c:\Users\HP\Documents\MATLAB\libsvm-3.11\windows\svmtrain.exe" -gnuplot c:\Downloads\gp444win32\gnuplot\binary\pgnuplot.exe-v 10 TrainVec Error : SyntaxError: invalid syntax what might be the error? 来源: https://stackoverflow.com/questions/8937358/query-over-grid-py

Kernlab kraziness: inconsistent results for identical problems

ぃ、小莉子 提交于 2019-12-12 12:19:39
问题 I've found some puzzling behavior in the kernlab package: estimating SVMs which are mathematically identical produces different results in software. This code snippet just takes the iris data and makes it a binary classification problem for the sake of simplicity. As you can see, I'm using linear kernels in both SVMs. library(kernlab) library(e1071) data(iris) x <- as.matrix(iris[, 1:4]) y <- as.factor(ifelse(iris[, 5] == 'versicolor', 1, -1)) C <- 5.278031643091578 svm1 <- ksvm(x = x, y = y,

ValueError: The number of classes has to be greater than one (python)

若如初见. 提交于 2019-12-12 10:49:22
问题 When passing x,y in fit , I am getting the following error: Traceback (most recent call last): File "C:/Classify/classifier.py", line 95, in train_avg, test_avg, cms = train_model(X, y, "ceps", plot=True) File "C:/Classify/classifier.py", line 47, in train_model clf.fit(X_train, y_train) File "C:\Python27\lib\site-packages\sklearn\svm\base.py", line 676, in fit raise ValueError("The number of classes has to be greater than" ValueError: The number of classes has to be greater than one. Below

MultiClass using LIBSVM

纵饮孤独 提交于 2019-12-12 09:24:03
问题 I have a multiclass svm classification(6 class). I would like to classify it using LIBSVM. The following are the ones that i have tried and i have some questions regarding them. Method1( one vs one): model = svmtrain(TrainLabel, TrainVec, '-c 1 -g 0.00154 -b 0.9'); [predict_label, accuracy, dec_values] = svmpredict(TestLabel, TestVec, model); Two questions about this method: 1) is that all i need to do for multiclass problem 2) what value should it be for n in '-b n'. I m not sure Method 2(