2014-09-02 2 views
0

랜덤 포레스트와 함께 Weka lib를 사용하는 작은 자바 애플리케이션을 구현했습니다. 나는 샘플 데이터로 약 85 %의 좋은 정확도를 얻는 몇몇 분류자를 훈련시켰다. 그러나 The Fast Random Forest (https://code.google.com/p/fast-random-forest/)를 사용하면 오류가 발생하기 시작합니다.빠른 랜덤 포레스트 알고리즘 구현

빠른 임의 포리스트를 구현하고 현재 jar 파일로 빌드했습니다. 이 현재 코드에 대한

"The method evaluateModel(Classifier, Instances, Object...) 
    in the type Evaluation is not applicable for the arguments 
    (FastRandomForest, Instances) " 

: 우리가 교육 자료의 분류 평가할 때, 다음과 같은 오류를주고 계속

FastRandomForest rTree = new FastRandomForest();   
    rTree.buildClassifier(trainingData); 

    showTree(rTree); 

    System.out.println("records: " + trainingData.attribute(classIndex)); 
    System.out.println("number of instances: " + trainingData.numInstances()); 
    System.out.println(trainingData.instance(1)); 
    System.out.println("target: " + trainingData.classAttribute()); 
    //System.out.println(rTree.classifyInstance(trainingData.instance(1))); 


    /* Evaluate the classifier on Training data */ 
    Evaluation eTest = new Evaluation(trainingData); 
    eTest.evaluateModel(rTree, trainingData); 
    String strSummary = eTest.toSummaryString(); 
    System.out.println(strSummary); 

도움말 감사를!

+1

스택 추적 please – StackFlowed

+0

'FastRandomForest'는'분류 자 '를 구현하거나 상속합니까? 이 메시지는 "분류 자 (Classifier)가 필요하지만 나에게 'FastRandomForest'를주었습니다. – Jonny

+0

Jonny, 아니요, FastRandomForest에서 Classifier를 확장하거나 구현하지 않습니다. 그게 원인 일 겁니다. – user2501165

답변

5

Classifier에 할당 할 수 없습니다. 을 작성하여 FastRandomForestClassifier처럼 작동하도록 할 수 있습니다.

public class FastRandomForestAdapter : Classifier { 
    private FastRandomForest frf; 
    public FastRandomForestAdpter(FastRandomForest frf) { 
    this.frf = frf; 
    } 

    @override 
    public void MethodA() { 
    frf.Method1(); 
    } 

    @override 
    public ReturnType MethodB(object arg) { 
    return frf.Method2(Transform(arg)); 
    } 

    private Transform(object a) { 
    ... 
    } 
} 
관련 문제