- Timestamp:
- 07/18/16 12:26:03 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalEMTraining.java
r99 r135 33 33 34 34 /** 35 * WekaLocalEMTraining 35 * <p> 36 * Local Trainer with EM Clustering for data partitioning. Currently supports only EM Clustering. 37 * </p> 38 * <ol> 39 * <li>Cluster training data</li> 40 * <li>for each cluster train a classifier with training data from cluster</li> 41 * <li>match test data instance to a cluster, then classify with classifier from the cluster</li> 42 * </ol> 36 43 * 37 * Local Trainer with EM Clustering for data partitioning. Currently supports only EM Clustering.44 * XML configuration: 38 45 * 39 * 1. Cluster training data 2. for each cluster train a classifier with training data from cluster 40 * 3. match test data instance to a cluster, then classify with classifier from the cluster 41 * 42 * XML configuration: <!-- because of clustering --> <preprocessor name="Normalization" param=""/> 43 * 44 * <!-- cluster trainer --> <trainer name="WekaLocalEMTraining" 45 * param="NaiveBayes weka.classifiers.bayes.NaiveBayes" /> 46 * <pre> 47 * {@code 48 * <trainer name="WekaLocalEMTraining" param="NaiveBayes weka.classifiers.bayes.NaiveBayes" /> 49 * } 50 * </pre> 46 51 */ 47 52 public class WekaLocalEMTraining extends WekaBaseTraining implements ITrainingStrategy { 48 53 54 /** 55 * the classifier 56 */ 49 57 private final TraindatasetCluster classifier = new TraindatasetCluster(); 50 58 59 /* 60 * (non-Javadoc) 61 * 62 * @see de.ugoe.cs.cpdp.training.WekaBaseTraining#getClassifier() 63 */ 51 64 @Override 52 65 public Classifier getClassifier() { … … 54 67 } 55 68 69 /* 70 * (non-Javadoc) 71 * 72 * @see de.ugoe.cs.cpdp.training.ITrainingStrategy#apply(weka.core.Instances) 73 */ 56 74 @Override 57 75 public void apply(Instances traindata) { … … 64 82 } 65 83 84 /** 85 * <p> 86 * Weka classifier for the local model with EM clustering. 87 * </p> 88 * 89 * @author Alexander Trautsch 90 */ 66 91 public class TraindatasetCluster extends AbstractClassifier { 67 92 93 /** 94 * default serializtion ID 95 */ 68 96 private static final long serialVersionUID = 1L; 69 97 98 /** 99 * EM clusterer used 100 */ 70 101 private EM clusterer = null; 71 102 103 /** 104 * classifiers for each cluster 105 */ 72 106 private HashMap<Integer, Classifier> cclassifier; 107 108 /** 109 * training data for each cluster 110 */ 73 111 private HashMap<Integer, Instances> ctraindata; 74 112 … … 107 145 } 108 146 147 /* 148 * (non-Javadoc) 149 * 150 * @see weka.classifiers.AbstractClassifier#classifyInstance(weka.core.Instance) 151 */ 109 152 @Override 110 153 public double classifyInstance(Instance instance) { … … 139 182 } 140 183 184 /* 185 * (non-Javadoc) 186 * 187 * @see weka.classifiers.Classifier#buildClassifier(weka.core.Instances) 188 */ 141 189 @Override 142 190 public void buildClassifier(Instances traindata) throws Exception {
Note: See TracChangeset
for help on using the changeset viewer.