Search in sources :

Example 21 with WekaAdapter

use of org.dkpro.tc.ml.weka.WekaAdapter in project dkpro-tc by dkpro.

the class WekaSaveAndLoadModelUnitTest method unitGetParameterSpace.

private static ParameterSpace unitGetParameterSpace() throws ResourceInitializationException {
    Map<String, Object> dimReaders = new HashMap<String, Object>();
    CollectionReaderDescription readerTrain = CollectionReaderFactory.createReaderDescription(BrownCorpusReader.class, BrownCorpusReader.PARAM_SOURCE_LOCATION, unitTrainFolder, BrownCorpusReader.PARAM_LANGUAGE, "en", BrownCorpusReader.PARAM_PATTERNS, Arrays.asList("*.xml"));
    dimReaders.put(DIM_READER_TRAIN, readerTrain);
    Map<String, Object> wekaConfig = new HashMap<>();
    wekaConfig.put(DIM_CLASSIFICATION_ARGS, new Object[] { new WekaAdapter(), SMO.class.getName() });
    wekaConfig.put(DIM_DATA_WRITER, new WekaAdapter().getDataWriterClass().getName());
    wekaConfig.put(DIM_FEATURE_USE_SPARSE, new WekaAdapter().useSparseFeatures());
    Dimension<Map<String, Object>> mlas = Dimension.createBundle("config", wekaConfig);
    Dimension<TcFeatureSet> dimFeatureSets = Dimension.create(DIM_FEATURE_SET, new TcFeatureSet(TcFeatureFactory.create(CharacterNGram.class, CharacterNGram.PARAM_NGRAM_USE_TOP_K, 20)));
    ParameterSpace pSpace = new ParameterSpace(Dimension.createBundle("readers", dimReaders), Dimension.create(DIM_LEARNING_MODE, LM_SINGLE_LABEL), Dimension.create(DIM_FEATURE_MODE, FM_UNIT), dimFeatureSets, mlas);
    return pSpace;
}
Also used : CollectionReaderDescription(org.apache.uima.collection.CollectionReaderDescription) SMO(weka.classifiers.functions.SMO) HashMap(java.util.HashMap) ParameterSpace(org.dkpro.lab.task.ParameterSpace) TcFeatureSet(org.dkpro.tc.api.features.TcFeatureSet) HashMap(java.util.HashMap) Map(java.util.Map) WekaAdapter(org.dkpro.tc.ml.weka.WekaAdapter)

Aggregations

HashMap (java.util.HashMap)21 ParameterSpace (org.dkpro.lab.task.ParameterSpace)21 WekaAdapter (org.dkpro.tc.ml.weka.WekaAdapter)21 Map (java.util.Map)19 TcFeatureSet (org.dkpro.tc.api.features.TcFeatureSet)18 CollectionReaderDescription (org.apache.uima.collection.CollectionReaderDescription)17 NaiveBayes (weka.classifiers.bayes.NaiveBayes)8 SMO (weka.classifiers.functions.SMO)5 ArrayList (java.util.ArrayList)4 File (java.io.File)3 List (java.util.List)3 CrfSuiteAdapter (org.dkpro.tc.ml.crfsuite.CrfSuiteAdapter)3 Test (org.junit.Test)3 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)2 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)2 AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)2 JCas (org.apache.uima.jcas.JCas)2 TextClassificationOutcome (org.dkpro.tc.api.type.TextClassificationOutcome)2 LiblinearAdapter (org.dkpro.tc.ml.liblinear.LiblinearAdapter)2 LibsvmAdapter (org.dkpro.tc.ml.libsvm.LibsvmAdapter)2