svm

Getting error using SVM with SURF

家住魔仙堡 提交于 2020-01-29 19:39:08
问题 Below is my code , which is running fine but after a long processing it show me the run time error // Initialize constant values const int nb_cars = files.size(); const int not_cars = files_no.size(); const int num_img = nb_cars + not_cars; // Get the number of images // Initialize your training set. cv::Mat training_mat(num_img,dictionarySize,CV_32FC1); cv::Mat labels(0,1,CV_32FC1); std::vector<string> all_names; all_names.assign(files.begin(),files.end()); all_names.insert(all_names.end(),

opencv svm使用总结

不想你离开。 提交于 2020-01-29 07:16:31
第一次需要使用opencv 来实现svm分类,记录一下大体的流程。 //---------- 头文件 #include <iostream> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include "opencv2/imgcodecs.hpp" #include <opencv2/highgui.hpp> #include <opencv2/ml.hpp> //ml模块 using namespace cv; using namespace cv::ml; //ml命名空间 using namespace std; //---------- 1. 随机生成训练数据(二维数据,超平面为二维) --- Mat trainData(2 * NTRAINING_SAMPLES, 2, CV_32FC1); Mat labels(2 * NTRAINING_SAMPLES, 1, CV_32SC1); //------------------ 2. 设置支持向量机范围 ------------- Ptr<SVM> svm = SVM::create(); //声明SVM对象 svm->setType(SVM::C_SVC); //SVM模型选择 svm->setC(0.2); //惩罚因子设置(原始0.1)

svm算法 最通俗易懂讲解

 ̄綄美尐妖づ 提交于 2020-01-28 04:50:46
最近在学习svm算法,借此文章记录自己的学习过程,在学习很多处借鉴了z老师的讲义和李航的统计,若有不足的地方,请海涵;svm算法通俗的理解在二维上,就是找一分割线把两类分开,问题是如下图三条颜色都可以把点和星划开,但哪条线是最优的呢,这就是我们要考虑的问题; 首先我们先假设一条直线为 W•X+b =0 为最优的分割线,把两类分开如下图所示,那我们就要解决的是怎么获取这条最优直线呢?及W 和 b 的值;在SVM中最优分割面(超平面)就是:能使 支持向量和超平面最小距离的最大值 ; 我们的目标是寻找一个超平面,使得离超平面比较近的点能有更大的间距。也就是我们不考虑所有的点都必须远离超平面,我们关心求得的超平面能够让所有点中离它最近的点具有最大间距。 如上面假设蓝色的星星类有5个样本,并设定此类样本标记为Y =1,紫色圈类有5个样本,并设定此类标记为 Y =-1,共 T ={(X₁ ,Y₁) , (X₂,Y₂) (X₃,Y₃) .........} 10个样本,超平面(分割线)为wx+b=0; 样本点到超平面的几何距离为: 此处要说明一下: 函数距离和几何距离的关系;定义上把 样本| w▪x₁+b|的距离叫做函数距离,而上面公式为几何距离,你会发现当w 和b 同倍数增加时候,函数距离也会通倍数增加;简单个例子就是,样本 X₁ 到 2w X₁ +2b =0的函数距离是w X₁ +b

Error “(subscript) logical subscript too long” with tune.svm from e1071 package in R

烈酒焚心 提交于 2020-01-25 20:42:06
问题 I am trying to use SVM for a multi-class classification task. I have a dataset called df , which I divided into a training and a test set with the following code: sample <- df[sample(nrow(df), 10000),] # take a random sample of 10,000 from dataset df sample <- sample %>% arrange(Date) # arrange chronologically train <- sample[1:8000,] # 80% of the df dataset test <- sample[8001:10000,] # 20% of the df dataset This is what the training set looks like: > str(train) 'data.frame': 8000 obs. of 45

SVM classification with always high precision

一曲冷凌霜 提交于 2020-01-25 13:27:30
问题 I have a binary classification problem and I'm trying to get precision-recall curve for my classifier. I use libsvm with RBF kernel and probability estimate option. To get the curve I'm changing decision threshold from 0 to 1 with steps of 0.1. But on every run, I get high precision even if recall decreases with increasing threshold. My false positive rate seems always low compared to true positives. My results are these: Threshold: 0.1 TOTAL TP:393, FP:1, FN: 49 Precision:0.997462, Recall: 0

SVM classification with always high precision

限于喜欢 提交于 2020-01-25 13:27:20
问题 I have a binary classification problem and I'm trying to get precision-recall curve for my classifier. I use libsvm with RBF kernel and probability estimate option. To get the curve I'm changing decision threshold from 0 to 1 with steps of 0.1. But on every run, I get high precision even if recall decreases with increasing threshold. My false positive rate seems always low compared to true positives. My results are these: Threshold: 0.1 TOTAL TP:393, FP:1, FN: 49 Precision:0.997462, Recall: 0

Differences of two-class svm in R(e1071) and WEKA(SMO)

*爱你&永不变心* 提交于 2020-01-24 20:44:08
问题 I generated a random data set like this: set.seed(1234) df <- data.frame(replicate(10, runif(100, 0, 1))) df$Class <- sample(c(-1,1), 100, replace=T) df$Class <- as.factor(df$Class) It has binary classes, 100 samples and 10 features. I tried using svm in R (e1071 package): library(e1071) set.seed(1234) model <- svm(Class~.,data=df,kernel="radial",cost=1.0,tolerance=0.001,epsilon=1.0E-12,scale=TRUE,cross=10) res <- predict(model, df[,-11]) table(pred=res, true=df[,11]) summary(res) summary(df

RCNN keras实现

蹲街弑〆低调 提交于 2020-01-24 19:32:54
代码地址: https://github.com/xiaoxu1025/rcnn-keras 这里仅仅只是做了个简单的实现 方便对论文有更深的理解 代码参考: https://blog.csdn.net/u014796085/article/details/83931150 https://github.com/yangxue0827/RCNN R-CNN分为三个部分 selective-search、特征抽取、svm 对于模型我这里是用的keras自带的VGG16来做特征抽取 from keras.applications.vgg16 import VGG16 from keras.models import Model from keras.layers import Dense, Flatten, Input def create_model(num_classes): input = Input(shape=(224, 224, 3)) vgg16_model = VGG16(input_tensor=input, include_top=False) # 弹出最后一层 x = vgg16_model.output x = Flatten(name='flatten')(x) x = Dense(4096, activation='relu', name='fc1')(x)

SMO,Sequential Minimal Optimization in WEKA

走远了吗. 提交于 2020-01-23 18:30:10
问题 I'm new with Weka. I want to use Sequential Minimal Optimization in WEKA. Could anyone tell me how to proceed? here is my Java code but it doesn't work: public class SVMTest { public void test(File input) throws Exception{ File tmp = new File("tmp-file-duplicate-pairs.arff"); String path = input.getParent(); //tmp.deleteOnExit(); ////removeFeatures(input,tmp,useType,useNames, useActivities, useOccupation,useFriends,useMailAndSite,useLocations); Instances data = new weka.core.converters

SMO,Sequential Minimal Optimization in WEKA

若如初见. 提交于 2020-01-23 18:29:16
问题 I'm new with Weka. I want to use Sequential Minimal Optimization in WEKA. Could anyone tell me how to proceed? here is my Java code but it doesn't work: public class SVMTest { public void test(File input) throws Exception{ File tmp = new File("tmp-file-duplicate-pairs.arff"); String path = input.getParent(); //tmp.deleteOnExit(); ////removeFeatures(input,tmp,useType,useNames, useActivities, useOccupation,useFriends,useMailAndSite,useLocations); Instances data = new weka.core.converters