2012-04-06 5 views
17

+/- 50,000 개의 기능이있는 +/- 13000 행을 포함하는 데이터 세트를 만들었습니다. 모든 분류 결과를 출력하는 방법을 알고 있습니다 : 예측과 실제,하지만 그 결과로 일종의 ID를 출력 할 수 있기를 바랍니다. 그래서 데이터 세트에 ID 열을 추가했지만 모든 예측 결과와 함께 ID를 출력 할 수있는 동안 분류 할 때 ID를 무시하는 방법을 모르겠습니다. 모든 예측과 함께 출력 할 기능을 선택하는 방법을 알고 있습니다.분류 할 때 기능을 건너 뛰지 만 출력에 기능을 표시합니다.

답변

11

필터링 된 분류자를 사용하십시오. thisthis을 참조하십시오.

+3

는'weka.filters를 사용합니다. 무관심. 속성. 제거하다. – drevicko

2

가 세리나

서비스
세트
놀라운 서비스를 제공 ..의 제거하려는 라인에 의해 파일 attributes.txt 라인에있는 bbcsport.arff의 속성이 때라도 가정 해 봅시다
테니스
타이 브레이크
대회
..윔블던
true 또는 false를 설정하여 특성을 포함 시키거나 제외시키는 방법은 다음과 같습니다. (상호 어려운) remove.setInvertSelection (거짓)

BufferedReader datafile = new BufferedReader(new FileReader("bbcsport.arff")); 
BufferedReader attrfile = new BufferedReader(new FileReader("attributes.txt")); 

Instances data = new Instances(datafile); 
List<Integer> myList = new ArrayList<Integer>(); 
String line; 

while ((line = attrfile.readLine()) != null) { 
    for (n = 0; n < data.numAttributes(); n++) { 
    if (data.attribute(n).name().equalsIgnoreCase(line)) { 
     if(!myList.contains(n)) 
     myList.add(n); 
    } 
    } 
} 

int[] attrs = myList.stream().mapToInt(i -> i).toArray(); 
Remove remove = new Remove(); 
remove.setAttributeIndicesArray(attrs); 
remove.setInvertSelection(false); 
remove.setInputFormat(data); // init filter 

Instances filtered = Filter.useFilter(data, remove); 

최종 속성이 '필터링'..

내 블로그 .. 필터로 http://ojaslabs.com/include-exclude-attributes-in-weka

관련 문제