Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bugfix for Issue #51

  • Loading branch information...
commit cdce3c1c55c46f02d8189f1d5894c6c03605d78f 1 parent 39db0a3
@ftesser ftesser authored
View
71 marytts-builder/src/main/java/marytts/tools/newlanguage/C45PruneableClassifierTreeWithUnary.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2012 DFKI GmbH.
+ * All Rights Reserved. Use is subject to license terms.
+ *
+ * This file is part of MARY TTS.
+ *
+ * MARY TTS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+package marytts.tools.newlanguage;
+
+import weka.classifiers.trees.j48.C45PruneableClassifierTree;
+import weka.classifiers.trees.j48.ModelSelection;
+import weka.core.Capabilities;
+import weka.core.Capabilities.Capability;
+
+/**
+ * This Class is a wrapper for C45PruneableClassifierTree that enables the UNARY_CLASS capability.
+ *
+ * @author Fabio Tesser
+ *
+ */
+
+public class C45PruneableClassifierTreeWithUnary extends C45PruneableClassifierTree {
+
+ public C45PruneableClassifierTreeWithUnary(ModelSelection toSelectLocModel,
+ boolean pruneTree, float cf, boolean raiseTree, boolean cleanup,
+ boolean collapseTree) throws Exception {
+ super(toSelectLocModel, pruneTree, cf, raiseTree, cleanup, collapseTree);
+ }
+
+
+ /**
+ * Returns default capabilities of the classifier tree.
+ *
+ * @return the capabilities of this classifier tree
+ */
+ public Capabilities getCapabilities() {
+ Capabilities result = super.getCapabilities();
+ result.disableAll();
+
+ // attributes
+ result.enable(Capability.NOMINAL_ATTRIBUTES);
+ result.enable(Capability.NUMERIC_ATTRIBUTES);
+ result.enable(Capability.DATE_ATTRIBUTES);
+ result.enable(Capability.MISSING_VALUES);
+ result.enable(Capability.UNARY_CLASS); // Can be used also with Unary
+
+ // class
+ result.enable(Capability.NOMINAL_CLASS);
+ result.enable(Capability.MISSING_CLASS_VALUES);
+
+ // instances
+ result.setMinimumNumberInstances(0);
+
+ return result;
+ }
+
+}
View
7 marytts-builder/src/main/java/marytts/tools/newlanguage/LTSTrainer.java
@@ -164,7 +164,7 @@ public CART trainTree(int minLeafData) throws IOException{
List<CART> stl = new ArrayList<CART>(fd.getNumberOfValues(centerGrapheme));
for (String gr : fd.getPossibleValues(centerGrapheme)){
-
+ System.out.println(" Training decision tree for: " + gr);
logger.debug(" Training decision tree for: " + gr);
ArrayList<Attribute> attributeDeclarations = new ArrayList<Attribute>();
@@ -222,10 +222,11 @@ public CART trainTree(int minLeafData) throws IOException{
// build the tree without using the J48 wrapper class
// standard parameters are:
- //binary split selection with minimum x instances at the leaves, tree is pruned, confidenced value, subtree raising, cleanup, don't collapse
+ // binary split selection with minimum x instances at the leaves, tree is pruned, confidenced value, subtree raising, cleanup, don't collapse
+ // Here is used a modifed version of C45PruneableClassifierTree that allow using Unary Classes (see Issue #51)
C45PruneableClassifierTree decisionTree;
try {
- decisionTree = new C45PruneableClassifierTree(new BinC45ModelSelection(minLeafData,data,true),true,0.25f,true,true, false);
+ decisionTree = new C45PruneableClassifierTreeWithUnary(new BinC45ModelSelection(minLeafData,data,true),true,0.25f,true,true, false);
decisionTree.buildClassifier(data);
} catch (Exception e) {
throw new RuntimeException("couldn't train decisiontree using weka: ", e);
Please sign in to comment.
Something went wrong with that request. Please try again.