svm

Plot SVM linear model trained by caret package in R

醉酒当歌 提交于 2020-07-22 03:19:38
问题 Purpose I was trying to visualize SVMLinear classification model via plot . I am using the example code and data provided in kernlab package having noticed caret actually train svm via ksvm function (referring to src code here (https://github.com/topepo/caret/blob/master/models/files/svmLinear.R)) Problem When I plot the final model of caret model object, it did not yield figure. And I did not find a way out after I tried three ways. Code require(caret) require(kernlab) # ===== sample codes

Plot SVM linear model trained by caret package in R

狂风中的少年 提交于 2020-07-22 03:18:12
问题 Purpose I was trying to visualize SVMLinear classification model via plot . I am using the example code and data provided in kernlab package having noticed caret actually train svm via ksvm function (referring to src code here (https://github.com/topepo/caret/blob/master/models/files/svmLinear.R)) Problem When I plot the final model of caret model object, it did not yield figure. And I did not find a way out after I tried three ways. Code require(caret) require(kernlab) # ===== sample codes

AttributeError: 'numpy.ndarray' object has no attribute 'lower'

柔情痞子 提交于 2020-07-03 12:00:28
问题 I am trying to predict using SVM but I receive the error AttributeError: 'numpy.ndarray' object has no attribute 'lower' when executing line text_clf.fit(X_train,y_train) of my code. How to fix this and get the probability that my prediction is correct using SVM? I am predicting the first column (gold) of my input file based on the values of the remaining columns. My input file dataExtended.txt is under the form: gold,T-x-T,T-x-N,T-x-U,T-x-NT,T-x-UT,T-x-UN,T-x-UNT,N-x-T,N-x-N,N-x-U,N-x-NT,N-x

Optimize F-score in e1071 package

…衆ロ難τιáo~ 提交于 2020-06-27 23:03:13
问题 I'm trying to implement a one class SVM using the e1071 package in R. Can somebody give me pointers on how to optimize the F-score using a grid search ? I have tried the tune.svm functions but it has only resulted in high sensitivity or high Specificity. The percentage of positive class which I'm trying to predict is about 1-2% in the general population. The results i get have high accuracy but with a very low F-score: Reference Prediction members Not members members 1 4 Not members 12 983

How to standardize data with sklearn's cross_val_score()

与世无争的帅哥 提交于 2020-06-13 20:06:49
问题 Let's say I want to use a LinearSVC to perform k-fold-cross-validation on a dataset. How would I perform standardization on the data? The best practice I have read is to build your standardization model on your training data then apply this model to the testing data. When one uses a simple train_test_split(), this is easy as we can just do: X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y) clf = svm.LinearSVC() scalar = StandardScaler() X_train = scalar.fit_transform(X

How to standardize data with sklearn's cross_val_score()

我只是一个虾纸丫 提交于 2020-06-13 20:03:31
问题 Let's say I want to use a LinearSVC to perform k-fold-cross-validation on a dataset. How would I perform standardization on the data? The best practice I have read is to build your standardization model on your training data then apply this model to the testing data. When one uses a simple train_test_split(), this is easy as we can just do: X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y) clf = svm.LinearSVC() scalar = StandardScaler() X_train = scalar.fit_transform(X

scikit-learn: what is the difference between SVC and SGD?

耗尽温柔 提交于 2020-05-25 08:34:04
问题 SVM: http://scikit-learn.org/stable/modules/svm.html#classification SGD: http://scikit-learn.org/stable/modules/sgd.html#classification seem to do pretty much the same to my eyes,as they write "an SGD implements a linear model". Can someone explain the differences between them? 回答1: SVM is a support-vector machine which is a special linear-model . From a theoretical view it's a convex-optimization problem and we can get the global-optimum in polynomial-time. There are many different

scikit-learn: what is the difference between SVC and SGD?

拥有回忆 提交于 2020-05-25 08:33:19
问题 SVM: http://scikit-learn.org/stable/modules/svm.html#classification SGD: http://scikit-learn.org/stable/modules/sgd.html#classification seem to do pretty much the same to my eyes,as they write "an SGD implements a linear model". Can someone explain the differences between them? 回答1: SVM is a support-vector machine which is a special linear-model . From a theoretical view it's a convex-optimization problem and we can get the global-optimum in polynomial-time. There are many different