svm

How to port the MATLAB libSVM parameters in C++

耗尽温柔 提交于 2019-12-24 05:24:28
问题 In my cross-validation in MATLAB with libSVM I found that these are the best parameters to use: model = svmtrain( labels, training, '-s 0 -t 2 -c 10000 -g 100'); Now I want to replicate the classification in C++ with OpenCV. But I do not understand how to set the C++ parameters to be the same as MATLAB: Based on this documentation I tried the following: CvSVMParams params; params.svm_type = CvSVM::C_SVC; params.kernel_type = CvSVM::RBF; //params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER,

Can I plot the SVM decision boundary for 3 features(in 3D space) using Scikit learn?

荒凉一梦 提交于 2019-12-24 05:24:05
问题 I am using scikit-learn to understand Support Vector Machines(SVM). I want to plot the decision boundary computed by SVM. The SVM uses 3 features. So the decision boundary must be drawn in 3D space. Is this possible using scikit-learn? I could find only 2D plots of SVM decision boundary at the official website. However I found links on stackoverflow which show this is possible using matlab and r. Is there a way in which I can achieve the same using scikit-learn? 回答1: You don't use scikit

在Python中实现SVM分类

半腔热情 提交于 2019-12-24 04:20:54
输入数据集,分析数据维度,可以看到共有0,1,2,3四个类别。 import pandas as pddf=pd.DataFrame({‘math’:[98,78,54,89,24,60,98,44,96,90],‘english’:[92,56,90,57,46,75,76,87,91,88],‘chinese’:[95,69,91,52,60,80,78,81,96,82],‘rank’:[0,3,2,3,1,1,2,2,0,0]}) 导入svm工具包。没有安装sklearn的要先安装svm。 from sklearn import svm 数据准备。本例中数据都是数值型变量,且没有空值,直接取X,y变量。 X=df.ix[:,[‘math’,‘english’,‘chinese’]] y=df[‘rank’] 建立模型,并进行训练。 clf = svm.SVC() clf.fit(X, y) 模型预测。有一组新的数据,根据模型预测它的分类,结果为rank=2。 new=[[60,51,98]] clf.predict(new) 绘制预测效果图。 y_pred=clf.predict(X) import matplotlib.pyplot as plt plt.figure() plt.scatter(range(len(y)),y, color=‘darkorange’,

How to extract features from image for classification and object recognition?

↘锁芯ラ 提交于 2019-12-24 00:33:20
问题 I'm confused about the way I should make the "features extraction " method I want to use SVMs to apply "Object recognition" in images , There's a sample in Emgu's examples that holds an XML file contains the features of a cat ! and I've been trying since a week to know how they did it and what methods they used and I came across this page http://experienceopencv.blogspot.com/2011/02/learning-deformable-models-with-latent.html that displays the steps ! It's so complicated plus couldn't do it

OpenCv SVM output file format

天涯浪子 提交于 2019-12-24 00:14:07
问题 I am implementing my own SVM rather than using OpenCV's svm class. I want the XML file that my SVM uses to save its output, can be loaded and used by OpenCV's SVM in future, if I wish. What should I need to do for that ? In short : what is the format that OpenCV uses to store its SVM output ? 回答1: You can follow OpenCV's CvSVM::write function. int i, var_count = get_var_count(), df_count, class_count; const CvSVMDecisionFunc* df = decision_func; cvStartWriteStruct( fs, name, CV_NODE_MAP, CV

用tensorflow实现SVM

旧巷老猫 提交于 2019-12-23 18:46:36
环境配置 win10 Python 3.6 tensorflow1.15 scipy matplotlib (运行时可能会遇到module tkinter的问题) sklearn 一个基于Python的第三方模块。sklearn库集成了一些常用的机器学习方法。 代码实现 import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets from tensorflow.python.framework import ops ops.reset_default_graph() sess = tf.Session() Session API Session的详细作用 Session是tensorflow中的一个执行OP和计算tensor的一个类。 framework API 补充: 张量(tensor):TensorFlow程序使用tensor数据结构来代表所有的数据,计算图中,操作间传递的数据都是tensor,你可以把TensorFlow tensor看做一个n维的数组或者列表。 变量(Var iable):常用于定义模型中的参数,是通过不断训练得到的值。比如权重和偏置。 占位符(placeholder):输入变量的载体

Are high values for c or gamma problematic when using an RBF kernel SVM?

拟墨画扇 提交于 2019-12-23 16:27:30
问题 I'm using WEKA/LibSVM to train a classifier for a term extraction system. My data is not linearly separable, so I used an RBF kernel instead of a linear one. I followed the guide from Hsu et al. and iterated over several values for both c and gamma. The parameters which worked best for classifying known terms (test and training material differ of course) are rather high, c=2^10 and gamma=2^3. So far the high parameters seem to work ok, yet I wonder if they may cause any problems further on,

Import an SVM model in PMML to Java or Python?

时光总嘲笑我的痴心妄想 提交于 2019-12-23 12:35:59
问题 Short question : is there a PMML interface for Java, Python or any other major programming language that supports SVM models? Background : I have trained an SVM model in R using the ksvm function from the kernlab package. Now I would like to use this model in a different piece of software. To export it from R, I think I could use PMML (Predictive Model Markup Language) via the pmml package for R. However, I can't find any library for Java, Python, or basically any language that allows for

value error happens when using GridSearchCV

馋奶兔 提交于 2019-12-23 09:34:30
问题 I am using GridSearchCV to do classification and my codes are: parameter_grid_SVM = {'dual':[True,False], 'loss':["squared_hinge","hinge"], 'penalty':["l1","l2"] } clf = GridSearchCV(LinearSVC(),param_grid=parameter_grid_SVM,verbose=2) clf.fit(trian_data, labels) And then, I meet the error ValueError: Unsupported set of arguments: penalty='l1' is only supported when dual='false'., Parameters: penalty='l1', loss='hinge', dual=False later on I change my code to : clf = GridSearchCV(LinearSVC

Error: Undefined function or method 'svmtrain' for input arguments of type 'double'

拜拜、爱过 提交于 2019-12-23 04:28:40
问题 I am running SVMStruct = svmtrain(xTrain, yTrain); and the error I get is Undefined function or method 'svmtrain' for input arguments of type 'double' I am pretty sure xTrain and yTrain are matrices though: size(xTrain) ans = 544 28 size(yTrain) ans = 544 1 Any idea what's going on here? 回答1: It sounds like the svmtrain function isn't on your path. If which svmtrain displays "svmtrain not found", then you should make sure that you have the bioinformatics toolbox (type ver and see if it is in