2015-01-23 6 views
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); 

누군가 알고 있나요?

미리 감사드립니다.

답변

0
  1. 기능 파일을 확인하십시오. 순서는 무엇입니까? 아니 아니, inf 또는 매우 큰 숫자?
  2. 교육 자료가 왜곡되어 있습니까? 즉 한 클래스에 대해 많은 가치가 있지만 다른 클래스에는 거의 가치가 없습니다.