Comments (6)
from libsvm.
from sklearn.datasets import laod_wine,load_breast_cancer. I deleted the target columns of two datasets and standardized them
from libsvm.
Could you show us your code?
from libsvm.
about what?Cpp code?
#include <svm.h>
#include <iostream>
class OneClassSvm2
{
public:
OneClassSvm2(string kernel, double nu, double gamma, double c);
~OneClassSvm2();
int getKernelType(string type);
void train(std::vector<svm_node*> data);
void predict(std::vector<svm_node*> data);
private:
int _kernel;
double _nu;
double _gamma;
double _C;
svm_model* model;
};
OneClassSvm2::OneClassSvm2(string kernel="rbf", double nu=0.5, double gamma=0.5, double c=1.0) {
this->_kernel = this->getKernelType(kernel);
this->_nu = nu;
this->_gamma = gamma;
this->_C = c;
this->model = nullptr;
}
OneClassSvm2::~OneClassSvm2() {
if (this->model != nullptr) {
svm_free_and_destroy_model(&this->model);
}
}
int OneClassSvm2::getKernelType(string type) {
if (type == "rbf") {
return RBF;
}
else if (type == "linear") {
return LINEAR;
}
else if (type == "poly") {
return POLY;
}
else if (type == "sigmoid") {
return SIGMOID;
}
}
void OneClassSvm2::train(std::vector<svm_node*> data) {
try {
int label_len = data.size();
std::vector<double> labels;
svm_parameter param;
param.svm_type = ONE_CLASS;
param.kernel_type = this->_kernel;
param.nu = this->_nu;
param.gamma = this->_gamma;
param.C = this->_C;
param.eps = 1e-6;
svm_problem prob;
for (int i = 0; i < label_len; i++) {
labels.push_back(1);
}
prob.l = label_len;
prob.y = labels.data();
prob.x = data.data();
this->model = svm_train(&prob, ¶m);
}
catch (const std::exception &e) {
cout << "训练异常:" << e.what() << endl;
}
}
void OneClassSvm2::predict(std::vector<svm_node*> data) {
vector<double> result;
try {
for (auto value : data) {
double predicted_label = svm_predict(model, value);
result.push_back(predicted_label);
std::cout << " " << predicted_label;
}
cout << "结果大小:" << result.size() << endl;
}
catch (const std::exception& e) {
cout << "预测异常:" << e.what() << endl;
}
}
When we examine the code, we find that there are no suitable parameters to control the iteration
from libsvm.
from libsvm.
We only need data and parameters to reproduce it. We did not make any changes to the code, it was just a simple call, so there are no relevant logs
from libsvm.
Related Issues (20)
- How to use the saved trained svm model file manually HOT 1
- how can i improve train speed? HOT 1
- why my memory always HOT 1
- Some dataset problem HOT 2
- static library HOT 1
- gridregression.py
- LIBSVM library not found HOT 1
- gridregression.py 出现 RuntimeError: get no mse HOT 2
- Exception Thrown: read access violation HOT 1
- 使用svm-train.exe做回归(regression),参数c与g如何优化 HOT 1
- How to modify SVR loss function? HOT 1
- Accuracies lower than 50% if the random seed is unlucky HOT 8
- one class svm HOT 1
- Questions about probability estimation of one-class svm HOT 4
- 如何调整nu,使训练集的准确率增加? HOT 6
- cannot find -lgcc: No such file or directory HOT 1
- When using svm-scale , missing values come out. HOT 1
- Try using a custom objective function
- MATLAB Crashes when trying to run "svmtrain" on CentOS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libsvm.