Commit 8210a6f2 authored by Markus Krug's avatar Markus Krug
Browse files

multiclass small adjustments

parent f60fb8df
......@@ -49,7 +49,6 @@ public class MulticlassMatrixUtil {
multiClassMapping.getMatrixMappings(matrix), instances, indexMap, beamSize);
multiClassMapping.addMapping(matrix.getGoldLabel(), mappingForMaximum);
}
}
......@@ -64,23 +63,8 @@ public class MulticlassMatrixUtil {
for (MatrixMcMatrixFace matrix : multiClass.getMatrices()) {
List<MatrixMapping> matrixMappings = multiClassMapping.getMatrixMappings(matrix);
//System.out.println("Before kron max score: " + matrix.getMaximumScore() + "Label: " + LabelAlphabet.getFeatureToId(matrix.getGoldLabel()));
//System.out.println(matrixMappings.get(matrixMappings.size()-1).getMappingMap().size());
// if(matrixMappings.get(matrixMappings.size()-1).getMappingMap().size()>0){
// HashMap<Point, Set<Point>> denseIndexToFeaturesMapping =
// matrixMappings.get(matrixMappings.size()-1).getDenseIndexToFeaturesMapping();
//
// //create a rule
// for(Set<Point> feats : denseIndexToFeaturesMapping.values()){
// RepresentationRule representationRule = new RepresentationRule(1,
// feats, matrix.getGoldLabel(), 1, 1);
// System.out.println(representationRule);
// }
// }
MatrixMcMatrixFace expandedMatrix = MatrixUtil.performKroneckerExpansion(matrixMappings, instances,
matrix.getGoldLabel());
//System.out.println("After kron max score: " + expandedMatrix.getMaximumScore());
//System.out.println();
multiClassMatrixMcMatrixFace.addMatrix(expandedMatrix);
}
......
......@@ -258,12 +258,16 @@ public class MultiClassRuleLearningAlgorithm implements IRepresentationRuleLearn
//System.out.println(getRuleForMaxEntry(multiClassMapping, maxEntryLocation, maximumScore, iterationMatrix));
// map matrix to dense matrix
long time = System.currentTimeMillis();
MulticlassMatrixUtil.getMappingForMaximum(iterationMatrix, maximumScore, maxEntryLocation.getLocation(),
multiClassMapping, instances, indexMap, beamSize);
System.out.println("Map:"+(System.currentTimeMillis() - time));
// assert that the maximum is within bounds
// expand in kronecker fashion
time = System.currentTimeMillis();
iterationMatrix = MulticlassMatrixUtil.performKroneckerExpansion(multiClassMapping, instances,
iterationMatrix);
System.out.println(System.currentTimeMillis()-time);
// check if a better rule can be learned
if (!betterRuleCanBeLearned(multiClassMapping, instances)) {
multiClassMapping.removeLastMapping();
......
......@@ -46,7 +46,7 @@ public class ExperimentCoNLLMulticlass {
File inTestB = new File("C:\\Users\\mkrug\\owncloud_neu\\paper_RegelLernen\\conll-xmi\\deu.testb.xmi.xmi");
File typesystem = new File("resources\\MiKalliTypesystem.xml");
MultiClassRuleLearningAlgorithm algorithm = new MultiClassRuleLearningAlgorithm(10);
MultiClassRuleLearningAlgorithm algorithm = new MultiClassRuleLearningAlgorithm(50);
//algorithm.skipTrainingForLabel("O-");
algorithm.setUseDropOut(new Random(42111337), 0.7);
TypeSystemDescription tsd = TypeSystemDescriptionFactory
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment