0
저는 LibSVM을 사용하는 대학의 C++에서 Support Vector Machine을 연구 중입니다. 문서 및 레이블로 가득 찬 .csv 파일을 구문 분석 할 수 있기를 원합니다. 이 지금까지 꽤 잘 작동하지만 출력으로 내가LibSVM에서 무의미한 출력
C = nan
obj = nan, rho = nan
nSV = 0, nBSV = 0
Total nSV = 0
을 얻을 좋은 데이터가 생성 된 것처럼이 보이지 않는다.
나는 초급자의 실수를 저지르고 있지만 무엇이 잘못 될지 알 수는 없다. 다음은 내가 사용하고있는 Document 클래스뿐만 아니라 노드를 작성하는 방법을 보여줍니다. 이유는 출력의 무의미에 대해 거짓말을 수있는 곳
class Document {
public:
double docID;
double label;
std::string text;
Document(double docID, double label, std::string aText);
}
...
std::vector<Feature> features = getFeatures();
documents = getDocuments();
int documentCount = documents.size();
int featureCount = features.size();
svm_node** nodesList = new svm_node*[documentCount];
double* labelList = new double[documentCount];
for (int j = 0; j < documentCount; j++){
nodesList[j] = new svm_node[featureCount];
Document currentDocument = documents[j];
for (int i = 0; i < featureCount; i++) {
svm_node node;
node.index = i + 1;
node.value = features[i].analyse(currentDocument.docID);
nodesList[j][i] = node;
}
labelList[j] = currentDocument.label;
}
problem->l = documentCount;
problem->x = nodesList;
problem->y = labelList;
param->svm_type = NU_SVC;
param->kernel_type = LINEAR;
param->degree = 3;
param->gamma = 0.0625;
param->coef0 = 0;
param->nu = 0.25;
param->cache_size = 100;
param->C = 1;
param->eps = 1e-3;
param->p = 0.1;
param->shrinking = 1;
param->probability = 0;
param->nr_weight = 0;
param->weight = new double[2];
param->weight_label = new int[2];
param->weight[0] = 1;
param->weight_label[0] = 1;
param->weight[1] = 1;
param->weight_label[1] = 1;
svm_check_parameter(problem, param);
model = svm_train(problem, param);
누군가 알고 있나요?
미리 감사드립니다.