svm

Convert sklearn.svm SVC classifier to Keras implementation

人走茶凉 提交于 2020-05-23 05:54:55
问题 I'm trying to convert some old code from using sklearn to Keras implementation. Since it is crucial to maintain the same way of operation, I want to understand if I'm doing it correctly. I've converted most of the code already, however I'm having trouble with sklearn.svm SVC classifier conversion. Here is how it looks right now: from sklearn.svm import SVC model = SVC(kernel='linear', probability=True) model.fit(X, Y_labels) Super easy, right. However, I couldn't find the analog of SVC

Convert sklearn.svm SVC classifier to Keras implementation

旧巷老猫 提交于 2020-05-23 05:54:09
问题 I'm trying to convert some old code from using sklearn to Keras implementation. Since it is crucial to maintain the same way of operation, I want to understand if I'm doing it correctly. I've converted most of the code already, however I'm having trouble with sklearn.svm SVC classifier conversion. Here is how it looks right now: from sklearn.svm import SVC model = SVC(kernel='linear', probability=True) model.fit(X, Y_labels) Super easy, right. However, I couldn't find the analog of SVC

Using an Accord.NET SVM for face recognition (MulticlassSupportVectorMachine)

こ雲淡風輕ζ 提交于 2020-04-30 08:11:55
问题 I am using OpenFace Windows binaries and Accord .NET to create a C# version of this Python-based face recognition system. OpenFace does most of the work, I just need to train an SVM to classify an unknown face (with probability), using known faces as the output classes. A "face" in this context is a CSV file full of face measurements. Simple enough in theory. As this seems best done with one-vs-rest methods, I am trying to work from the MulticlassSupportVectorMachine example in the API.

Using an Accord.NET SVM for face recognition (MulticlassSupportVectorMachine)

我与影子孤独终老i 提交于 2020-04-30 08:11:08
问题 I am using OpenFace Windows binaries and Accord .NET to create a C# version of this Python-based face recognition system. OpenFace does most of the work, I just need to train an SVM to classify an unknown face (with probability), using known faces as the output classes. A "face" in this context is a CSV file full of face measurements. Simple enough in theory. As this seems best done with one-vs-rest methods, I am trying to work from the MulticlassSupportVectorMachine example in the API.

Hyperopt tuning parameters get stuck

寵の児 提交于 2020-04-17 21:39:17
问题 I'm testing to tune parameters of SVM with hyperopt library. Often, when i execute this code, the progress bar stop and the code get stuck. I do not understand why. Here is my code : from hyperopt import fmin, tpe, hp, STATUS_OK, Trials X_train = normalize(X_train) def hyperopt_train_test(params): if 'decision_function_shape' in params: if params['decision_function_shape'] == "ovo": params['break_ties'] = False clf = svm.SVC(**params) y_pred = clf.fit(X_train, y_train).predict(X_test) return

How to get all alpha values of scikit-learn SVM classifier?

醉酒当歌 提交于 2020-04-13 05:06:13
问题 I need the alpha values, which are the Lagrange multipliers of the SVM dual problem, after training a SVM classifier with scikit-learn. According to the document, it seems that scikit-learn provides only svm.dual_coef_ , which is the product of the Lagrange multiplier alpha and the label of a data point. I tried to calculate the alpha value manually by dividing the elements of svm.dual_coef_ by the data label, but since svm.dual_coef_ stores only the coefficients of the support vectors, I'm

How to get all alpha values of scikit-learn SVM classifier?

邮差的信 提交于 2020-04-13 04:59:29
问题 I need the alpha values, which are the Lagrange multipliers of the SVM dual problem, after training a SVM classifier with scikit-learn. According to the document, it seems that scikit-learn provides only svm.dual_coef_ , which is the product of the Lagrange multiplier alpha and the label of a data point. I tried to calculate the alpha value manually by dividing the elements of svm.dual_coef_ by the data label, but since svm.dual_coef_ stores only the coefficients of the support vectors, I'm

One Class SVM algorithm taking too long

冷暖自知 提交于 2020-04-10 09:54:09
问题 The data bellow shows part of my dataset, that is used to detect anomalies describe_file data_numbers index 0 gkivdotqvj 7309.0 0 1 hpwgzodlky 2731.0 1 2 dgaecubawx 0.0 2 3 NaN 0.0 3 4 lnpeyxsrrc 0.0 4 I used One Class SVM algorithm to detect anomalies from pyod.models.ocsvm import OCSVM random_state = np.random.RandomState(42) outliers_fraction = 0.05 classifiers = { 'One Classify SVM (SVM)':OCSVM(kernel='rbf', degree=3, gamma='auto', coef0=0.0, tol=0.001, nu=0.5, shrinking=True, cache_size

Evaluating the performance of one class SVM

丶灬走出姿态 提交于 2020-04-07 06:36:27
问题 I have been trying to evaluate the performance of my one-class SVM. I have tried plotting an ROC curve using scikit-learn, and the results have been a bit bizarre. X_train, X_test = train_test_split(compressed_dataset,test_size = 0.5,random_state = 42) clf = OneClassSVM(nu=0.1,kernel = "rbf", gamma =0.1) y_score = clf.fit(X_train).decision_function(X_test) pred = clf.predict(X_train) fpr,tpr,thresholds = roc_curve(pred,y_score) # Plotting roc curve plt.figure() plt.plot(fpr, tpr, label='ROC

机器学习第5章支持向量机

久未见 提交于 2020-03-28 18:48:05
参考:作者的 Jupyter Notebook Chapter 5 – Support Vector Machines 支持向量机(简称SVM)是一个功能强大并且全面的机器学习模型,它能够执行线性或非线性分类、回归,甚至是异常值检测任务。它是机器学习领域最受欢迎的模型之一,任何对机器学习感兴趣的人都应该在工具箱中配备一个。SVM特别适用于中小型复杂数据集的分类。 保存图片 from __future__ import division, print_function, unicode_literals import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import os np.random.seed(42) mpl.rc('axes', labelsize=14) mpl.rc('xtick', labelsize=12) mpl.rc('ytick', labelsize=12) # Where to save the figures PROJECT_ROOT_DIR = "images" CHAPTER_ID = "traininglinearmodels" def save_fig(fig_id, tight_layout=True): path = os.path.join