Search in sources :

Example 1 with ASSearch

use of weka.attributeSelection.ASSearch in project dkpro-tc by dkpro.

the class WekaUtils method singleLabelAttributeSelection.

/**
 * Feature selection using Weka.
 *
 * @param trainData
 *            weka train data
 * @param featureSearcher
 *            list of features
 * @param attributeEvaluator
 *            list of attribute evaluators
 * @return attribute selection
 * @throws Exception
 *             in case of errors
 */
public static AttributeSelection singleLabelAttributeSelection(Instances trainData, List<String> featureSearcher, List<String> attributeEvaluator) throws Exception {
    AttributeSelection selector = new AttributeSelection();
    // Get feature searcher
    ASSearch search = ASSearch.forName(featureSearcher.get(0), featureSearcher.subList(1, featureSearcher.size()).toArray(new String[0]));
    // Get attribute evaluator
    ASEvaluation evaluation = ASEvaluation.forName(attributeEvaluator.get(0), attributeEvaluator.subList(1, attributeEvaluator.size()).toArray(new String[0]));
    selector.setSearch(search);
    selector.setEvaluator(evaluation);
    selector.SelectAttributes(trainData);
    return selector;
}
Also used : ASEvaluation(weka.attributeSelection.ASEvaluation) AttributeSelection(weka.attributeSelection.AttributeSelection) ASSearch(weka.attributeSelection.ASSearch)

Aggregations

ASEvaluation (weka.attributeSelection.ASEvaluation)1 ASSearch (weka.attributeSelection.ASSearch)1 AttributeSelection (weka.attributeSelection.AttributeSelection)1