weka.core.OptionHandler Java Examples

The following examples show how to use weka.core.OptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WekaUtil.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
public static String getDescriptor(final Object o) {
	StringBuilder sb = new StringBuilder();
	sb.append(o.getClass().getName());
	if (o instanceof OptionHandler) {
		sb.append("- [");
		int i = 0;
		for (String s : ((OptionHandler) o).getOptions()) {
			if (i++ > 0) {
				sb.append(", ");
			}
			sb.append(s);
		}
		sb.append("]");
	}
	return sb.toString();
}
 
Example #2
Source File: Stacking.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String [] getOptions() {

  String [] superOptions = super.getOptions();
  String [] options = new String [superOptions.length + 4];

  int current = 0;
  options[current++] = "-X"; options[current++] = "" + getNumFolds();
  options[current++] = "-M";
  options[current++] = getMetaClassifier().getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)getMetaClassifier()).getOptions());

  System.arraycopy(superOptions, 0, options, current, 
     superOptions.length);
  return options;
}
 
Example #3
Source File: SingleAssociatorEnhancer.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Gets the current settings of the associator.
  *
  * @return 		an array of strings suitable for passing to setOptions
  */
 public String[] getOptions() {
   int       		i;
   Vector<String>    	result;
   String[]		options;
   
   result = new Vector<String>();

   result.add("-W");
   result.add(getAssociator().getClass().getName());

   if (getAssociator() instanceof OptionHandler) {
     options = ((OptionHandler) getAssociator()).getOptions();
     result.add("--");
     for (i = 0; i < options.length; i++)
result.add(options[i]);
   }

   return result.toArray(new String[result.size()]);
 }
 
Example #4
Source File: WekaClassifier.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public IReconstructionPlan getConstructionPlan() {
	try {
		if (this.wrappedClassifier instanceof MLPipeline) {
			MLPipeline pipeline = (MLPipeline) this.wrappedClassifier;
			Classifier classifier = pipeline.getBaseClassifier();
			ASSearch searcher = pipeline.getPreprocessors().get(0).getSearcher();
			ASEvaluation evaluator = pipeline.getPreprocessors().get(0).getEvaluator();
			return new ReconstructionPlan(
					Arrays.asList(new ReconstructionInstruction(WekaClassifier.class.getMethod("createPipeline", String.class, List.class, String.class, List.class, String.class, List.class), searcher.getClass().getName(),
							((OptionHandler) searcher).getOptions(), evaluator.getClass().getName(), ((OptionHandler) evaluator).getOptions(), classifier.getClass().getName(), ((OptionHandler) classifier).getOptions())));
		} else {
			return new ReconstructionPlan(Arrays.asList(new ReconstructionInstruction(WekaClassifier.class.getMethod("createBaseClassifier", String.class, List.class), this.name, this.getOptionsAsList())));
		}
	} catch (NoSuchMethodException | SecurityException e) {
		throw new UnsupportedOperationException(e);
	}
}
 
Example #5
Source File: SingleClustererEnhancer.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Returns an enumeration describing the available options.
  *
  * @return 		an enumeration of all the available options.
  */
 public Enumeration listOptions() {
   Vector result = new Vector();

   result.addElement(new Option(
"\tFull name of base clusterer.\n"
+ "\t(default: " + defaultClustererString() +")",
"W", 1, "-W"));

   if (m_Clusterer instanceof OptionHandler) {
     result.addElement(new Option(
  "",
  "", 0, "\nOptions specific to clusterer "
  + m_Clusterer.getClass().getName() + ":"));
     Enumeration enu = ((OptionHandler) m_Clusterer).listOptions();
     while (enu.hasMoreElements()) {
result.addElement(enu.nextElement());
     }
   }

   return result.elements();
 }
 
Example #6
Source File: Filter.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the format of output instances. The derived class should use this
 * method once it has determined the outputformat. The 
 * output queue is cleared.
 *
 * @param outputFormat the new output format
 */
protected void setOutputFormat(Instances outputFormat) {

  if (outputFormat != null) {
    m_OutputFormat = outputFormat.stringFreeStructure();
    initOutputLocators(m_OutputFormat, null);

    // Rename the relation
    String relationName = outputFormat.relationName() 
      + "-" + this.getClass().getName();
    if (this instanceof OptionHandler) {
      String [] options = ((OptionHandler)this).getOptions();
      for (int i = 0; i < options.length; i++) {
        relationName += options[i].trim();
      }
    }
    m_OutputFormat.setRelationName(relationName);
  } else {
    m_OutputFormat = null;
  }
  m_OutputQueue = new Queue();
}
 
Example #7
Source File: ClassificationViaClustering.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * returns the options of the current setup
 *
 * @return		the current options
 */
public String[] getOptions(){
  int       		i;
  Vector<String>    	result;
  String[]  		options;

  result = new Vector<String>();

  result.add("-W");
  result.add("" + getClusterer().getClass().getName());
  
  options = super.getOptions();
  for (i = 0; i < options.length; i++)
    result.add(options[i]);

  if (getClusterer() instanceof OptionHandler) {
    result.add("--");
    options = ((OptionHandler) getClusterer()).getOptions();
    for (i = 0; i < options.length; i++)
      result.add(options[i]);
  }

  return result.toArray(new String[result.size()]);	  
}
 
Example #8
Source File: PartitionMembership.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the current settings of the filter.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String [] getOptions() {
  
  String [] generatorOptions = new String [0];
  if ((m_partitionGenerator != null) &&
      (m_partitionGenerator instanceof OptionHandler)) {
    generatorOptions = ((OptionHandler)m_partitionGenerator).getOptions();
  }
  String [] options = new String [generatorOptions.length + 3];
  int current = 0;
  
  if (m_partitionGenerator != null) {
    options[current++] = "-W"; 
    options[current++] = getPartitionGenerator().getClass().getName();
  }
  
  options[current++] = "--";
  System.arraycopy(generatorOptions, 0, options, current,
                   generatorOptions.length);
  current += generatorOptions.length;
  
  while (current < options.length) {
    options[current++] = "";
  }
  return options;
}
 
Example #9
Source File: CheckSource.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String[] getOptions() {
  Vector<String>      result;

  result  = new Vector<String>();

  if (getClassifier() != null) {
    result.add("-W");
    result.add(getClassifier().getClass().getName() + " "
        + Utils.joinOptions(((OptionHandler) getClassifier()).getOptions()));
  }

  if (getSourceCode() != null) {
    result.add("-S");
    result.add(getSourceCode().getClass().getName());
  }

  if (getDataset() != null) {
    result.add("-t");
    result.add(m_Dataset.getAbsolutePath());
  }

  result.add("-c");
  if (getClassIndex() == -1)
    result.add("last");
  else if (getClassIndex() == 0)
    result.add("first");
  else
    result.add("" + (getClassIndex() + 1));

  return result.toArray(new String[result.size()]);
}
 
Example #10
Source File: BVDecompose.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the current settings of the CheckClassifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String [] getOptions() {

  String [] classifierOptions = new String [0];
  if ((m_Classifier != null) &&
      (m_Classifier instanceof OptionHandler)) {
    classifierOptions = ((OptionHandler)m_Classifier).getOptions();
      }
  String [] options = new String [classifierOptions.length + 14];
  int current = 0;
  if (getDebug()) {
    options[current++] = "-D";
  }
  options[current++] = "-c"; options[current++] = "" + getClassIndex();
  options[current++] = "-x"; options[current++] = "" + getTrainIterations();
  options[current++] = "-T"; options[current++] = "" + getTrainPoolSize();
  options[current++] = "-s"; options[current++] = "" + getSeed();
  if (getDataFileName() != null) {
    options[current++] = "-t"; options[current++] = "" + getDataFileName();
  }
  if (getClassifier() != null) {
    options[current++] = "-W";
    options[current++] = getClassifier().getClass().getName();
  }
  options[current++] = "--";
  System.arraycopy(classifierOptions, 0, options, current,
      classifierOptions.length);
  current += classifierOptions.length;
  while (current < options.length) {
    options[current++] = "";
  }
  return options;
}
 
Example #11
Source File: BVDecomposeSegCVSub.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns description of the bias-variance decomposition results.
 *
 * @return the bias-variance decomposition results as a string
 */
public String toString() {

    String result = "\nBias-Variance Decomposition Segmentation, Cross Validation\n" +
    "with subsampling.\n";

    if (getClassifier() == null) {
        return "Invalid setup";
    }

    result += "\nClassifier    : " + getClassifier().getClass().getName();
    if (getClassifier() instanceof OptionHandler) {
        result += Utils.joinOptions(((OptionHandler)m_Classifier).getOptions());
    }
    result += "\nData File     : " + getDataFileName();
    result += "\nClass Index   : ";
    if (getClassIndex() == 0) {
        result += "last";
    } else {
        result += getClassIndex();
    }
    result += "\nIterations    : " + getClassifyIterations();
    result += "\np             : " + getP();
    result += "\nTraining Size : " + getTrainSize();
    result += "\nSeed          : " + getSeed();

    result += "\n\nDefinition   : " +"Kohavi and Wolpert";
    result += "\nError         :" + Utils.doubleToString(getError(), 4);
    result += "\nBias^2        :" + Utils.doubleToString(getKWBias(), 4);
    result += "\nVariance      :" + Utils.doubleToString(getKWVariance(), 4);
    result += "\nSigma^2       :" + Utils.doubleToString(getKWSigma(), 4);

    result += "\n\nDefinition   : " +"Webb";
    result += "\nError         :" + Utils.doubleToString(getError(), 4);
    result += "\nBias          :" + Utils.doubleToString(getWBias(), 4);
    result += "\nVariance      :" + Utils.doubleToString(getWVariance(), 4);

    return result;
}
 
Example #12
Source File: DecisionTable.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the search specification string, which contains the class name of
 * the search method and any options to it
 *
 * @return the search string.
 */
protected String getSearchSpec() {

  ASSearch s = getSearch();
  if (s instanceof OptionHandler) {
    return s.getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)s).getOptions());
  }
  return s.getClass().getName();
}
 
Example #13
Source File: RankSearch.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an enumeration describing the available options.
 * @return an enumeration of all the available options.
 **/
public Enumeration listOptions () {
  Vector newVector = new Vector(4);
  
  newVector.addElement(new Option(
      "\tclass name of attribute evaluator to use for ranking. Place any\n" 
      + "\tevaluator options LAST on the command line following a \"--\".\n" 
      + "\teg.:\n"
      + "\t\t-A weka.attributeSelection.GainRatioAttributeEval ... -- -M\n"
      + "\t(default: weka.attributeSelection.GainRatioAttributeEval)", 
      "A", 1, "-A <attribute evaluator>"));
  
  newVector.addElement(new Option(
      "\tnumber of attributes to be added from the"
      +"\n\tranking in each iteration (default = 1).", 
      "S", 1,"-S <step size>"));
  
  newVector.addElement(new Option(
      "\tpoint in the ranking to start evaluating from. "
      +"\n\t(default = 0, ie. the head of the ranking).", 
      "R", 1,"-R <start point>"));

  if ((m_ASEval != null) && 
      (m_ASEval instanceof OptionHandler)) {
    newVector.addElement(new Option("", "", 0, "\nOptions specific to " 
                                    + "evaluator " 
                                    + m_ASEval.getClass().getName() 
                                    + ":"));
    Enumeration enu = ((OptionHandler)m_ASEval).listOptions();

    while (enu.hasMoreElements()) {
      newVector.addElement(enu.nextElement());
    }
  }

  return newVector.elements();
}
 
Example #14
Source File: TextDirectoryLoader.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Main method.
  *
  * @param args should contain the name of an input file.
  */
 public static void main(String[] args) {
   if (args.length > 0) {
     try {
TextDirectoryLoader loader = new TextDirectoryLoader();
loader.setOptions(args);
//System.out.println(loader.getDataSet());
Instances structure = loader.getStructure();
System.out.println(structure);
Instance temp;
do {
  temp = loader.getNextInstance(structure);
  if (temp != null) {
    System.out.println(temp);
  }
} while (temp != null);
     } 
     catch (Exception e) {
e.printStackTrace();
     }
   } 
   else {
     System.err.println(
  "\nUsage:\n" 
  + "\tTextDirectoryLoader [options]\n"
  + "\n"
  + "Options:\n");

     Enumeration enm = ((OptionHandler) new TextDirectoryLoader()).listOptions();
     while (enm.hasMoreElements()) {
Option option = (Option) enm.nextElement();
System.err.println(option.synopsis());
System.err.println(option.description());
     }
     
     System.err.println();
   }
 }
 
Example #15
Source File: SingleClassifierEnhancer.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the current settings of the Classifier.
 *
 * @return an array of strings suitable for passing to setOptions
 */
public String [] getOptions() {

  String [] classifierOptions = ((OptionHandler)m_Classifier).getOptions();
  int extraOptionsLength = classifierOptions.length;
  if (extraOptionsLength > 0) {
    extraOptionsLength++; // for the double hyphen
  }

  String [] superOptions = super.getOptions();
  String [] options = new String [superOptions.length +
    extraOptionsLength + 2];

  int current = 0;
  options[current++] = "-W";
  options[current++] = getClassifier().getClass().getName();

  System.arraycopy(superOptions, 0, options, current,
      superOptions.length);
  current += superOptions.length;

  if (classifierOptions.length > 0) {
    options[current++] = "--";
    System.arraycopy(classifierOptions, 0, options, current,
        classifierOptions.length);
  }

  return options;
}
 
Example #16
Source File: SingleClassifierEnhancer.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the classifier specification string, which contains the class name of
 * the classifier and any options to the classifier
 *
 * @return the classifier string
 */
protected String getClassifierSpec() {

  Classifier c = getClassifier();
  return c.getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)c).getOptions());
}
 
Example #17
Source File: OptionUtils.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the array to the options.
 *
 * @param options   the current list of options to extend
 * @param option    the option (without the leading dash)
 * @param value     the current value
 */
public static void add(List<String> options, String option, Object value) {
	if (!value.getClass().isArray())
		throw new IllegalArgumentException("Value is not an array!");
	for (int i = 0; i < Array.getLength(value); i++) {
		Object element = Array.get(value, i);
		if (element instanceof OptionHandler) {
			add(options, option, (OptionHandler) element);
		}
		else {
			options.add("-" + option);
			options.add("" + element);
		}
	}
}
 
Example #18
Source File: RemoveMisclassified.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the classifier specification string, which contains the class name of
  * the classifier and any options to the classifier.
  *
  * @return the classifier string.
  */
 protected String getClassifierSpec() {
   
   Classifier c = getClassifier();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example #19
Source File: MultipleClassifiersCombiner.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the classifier specification string, which contains the class name of
 * the classifier and any options to the classifier
 *
 * @param index the index of the classifier string to retrieve, starting from
 * 0.
 * @return the classifier string, or the empty string if no classifier
 * has been assigned (or the index given is out of range).
 */
protected String getClassifierSpec(int index) {

  if (m_Classifiers.length < index) {
    return "";
  }
  Classifier c = getClassifier(index);
  return c.getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)c).getOptions());
}
 
Example #20
Source File: MISVM.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Returns an enumeration describing the available options
  *
  * @return an enumeration of all the available options
  */
 public Enumeration listOptions() {
   Vector result = new Vector();
   
   Enumeration enm = super.listOptions();
   while (enm.hasMoreElements())
     result.addElement(enm.nextElement());

   result.addElement(new Option(
         "\tThe complexity constant C. (default 1)",
         "C", 1, "-C <double>"));
   
   result.addElement(new Option(
       "\tWhether to 0=normalize/1=standardize/2=neither.\n"
       + "\t(default: 0=normalize)",
       "N", 1, "-N <default 0>"));
 
   result.addElement(new Option(
       "\tThe maximum number of iterations to perform.\n"
       + "\t(default: 500)",
       "I", 1, "-I <num>"));
 
   result.addElement(new Option(
"\tThe Kernel to use.\n"
+ "\t(default: weka.classifiers.functions.supportVector.PolyKernel)",
"K", 1, "-K <classname and parameters>"));

   result.addElement(new Option(
"",
"", 0, "\nOptions specific to kernel "
+ getKernel().getClass().getName() + ":"));
   
   enm = ((OptionHandler) getKernel()).listOptions();
   while (enm.hasMoreElements())
     result.addElement(enm.nextElement());

   return result.elements();
 }
 
Example #21
Source File: CVParameterSelection.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the current settings of the Classifier.
  *
  * @return an array of strings suitable for passing to setOptions
  */
 public String [] getOptions() {

   String[] superOptions;

   if (m_InitOptions != null) {
     try {
((OptionHandler)m_Classifier).setOptions((String[])m_InitOptions.clone());
superOptions = super.getOptions();
((OptionHandler)m_Classifier).setOptions((String[])m_BestClassifierOptions.clone());
     } catch (Exception e) {
throw new RuntimeException("CVParameterSelection: could not set options " +
			   "in getOptions().");
     } 
   } else {
     superOptions = super.getOptions();
   }
   String [] options = new String [superOptions.length + m_CVParams.size() * 2 + 2];

   int current = 0;
   for (int i = 0; i < m_CVParams.size(); i++) {
     options[current++] = "-P"; options[current++] = "" + getCVParameter(i);
   }
   options[current++] = "-X"; options[current++] = "" + getNumFolds();

   System.arraycopy(superOptions, 0, options, current, 
	     superOptions.length);

   return options;
 }
 
Example #22
Source File: CostSensitiveClassifier.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the classifier specification string, which contains the class name of
  * the classifier and any options to the classifier
  *
  * @return the classifier string.
  */
 protected String getClassifierSpec() {
   
   Classifier c = getClassifier();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example #23
Source File: FilteredClassifier.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the filter specification string, which contains the class name of
  * the filter and any options to the filter
  *
  * @return the filter string.
  */
 protected String getFilterSpec() {
   
   Filter c = getFilter();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example #24
Source File: MetaCost.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the classifier specification string, which contains the
 * class name of the classifier and any options to the classifier
 *
 * @return the classifier string.
 */
protected String getClassifierSpec() {
  
  Classifier c = getClassifier();
  return c.getClass().getName() + " "
    + Utils.joinOptions(((OptionHandler)c).getOptions());
}
 
Example #25
Source File: RotationForest.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the filter specification string, which contains the class name of
  * the filter and any options to the filter
  *
  * @return the filter string.
  */
 /* Taken from FilteredClassifier */
 protected String getProjectionFilterSpec() {
   
   Filter c = getProjectionFilter();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example #26
Source File: MultiScheme.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the classifier specification string, which contains the class name of
  * the classifier and any options to the classifier
  *
  * @param index the index of the classifier string to retrieve, starting from
  * 0.
  * @return the classifier string, or the empty string if no classifier
  * has been assigned (or the index given is out of range).
  */
 protected String getClassifierSpec(int index) {
   
   if (m_Classifiers.length < index) {
     return "";
   }
   Classifier c = getClassifier(index);
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example #27
Source File: CheckEstimator.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
public Enumeration listOptions() {
  
  Vector newVector = new Vector(2);
  
  newVector.addElement(new Option(
      "\tTurn on debugging output.",
      "D", 0, "-D"));
  
  newVector.addElement(new Option(
      "\tSilent mode - prints nothing to stdout.",
      "S", 0, "-S"));
  
  newVector.addElement(new Option(
      "\tThe number of instances in the datasets (default 100).",
      "N", 1, "-N <num>"));
  
  newVector.addElement(new Option(
      "\tFull name of the estimator analysed.\n"
      +"\teg: weka.estimators.NormalEstimator",
      "W", 1, "-W"));
  
  if ((m_Estimator != null) 
      && (m_Estimator instanceof OptionHandler)) {
    newVector.addElement(new Option("", "", 0, 
        "\nOptions specific to estimator "
        + m_Estimator.getClass().getName()
        + ":"));
    Enumeration enu = ((OptionHandler)m_Estimator).listOptions();
    while (enu.hasMoreElements())
      newVector.addElement(enu.nextElement());
  }
  
  return newVector.elements();
}
 
Example #28
Source File: FilteredSubsetEval.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the evaluator + options as a string
 *
 * @return a String containing the name of the evalautor + any options
 */
protected String getEvaluatorSpec() {
  SubsetEvaluator a = m_evaluator;
  if (a instanceof OptionHandler) {
    return a.getClass().getName() + " "
      + Utils.joinOptions(((OptionHandler)a).getOptions());
  }
  return a.getClass().getName();
}
 
Example #29
Source File: RankSearch.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * returns a description of the search as a String
 * @return a description of the search
 */
public String toString () {
  StringBuffer text = new StringBuffer();
  text.append("\tRankSearch :\n");
  text.append("\tAttribute evaluator : "
              + getAttributeEvaluator().getClass().getName() +" ");
  if (m_ASEval instanceof OptionHandler) {
    String[] evaluatorOptions = new String[0];
    evaluatorOptions = ((OptionHandler)m_ASEval).getOptions();
    for (int i=0;i<evaluatorOptions.length;i++) {
      text.append(evaluatorOptions[i]+' ');
    }
  }
  text.append("\n");
  text.append("\tAttribute ranking : \n");
  int rlength = (int)(Math.log(m_Ranking.length) / Math.log(10) + 1);
  for (int i=0;i<m_Ranking.length;i++) {
    text.append("\t "+Utils.doubleToString((double)(m_Ranking[i]+1),
                                           rlength,0)
                +" "+m_Instances.attribute(m_Ranking[i]).name()+'\n');
  }
  text.append("\tMerit of best subset found : ");
  int fieldwidth = 3;
  double precision = (m_bestMerit - (int)m_bestMerit);
  if (Math.abs(m_bestMerit) > 0) {
    fieldwidth = (int)Math.abs((Math.log(Math.abs(m_bestMerit)) / Math.log(10)))+2;
  }
  if (Math.abs(precision) > 0) {
    precision = Math.abs((Math.log(Math.abs(precision)) / Math.log(10)))+3;
  } else {
    precision = 2;
  }

  text.append(Utils.doubleToString(Math.abs(m_bestMerit),
                                   fieldwidth+(int)precision,
                                   (int)precision)+"\n");
  return text.toString();
}
 
Example #30
Source File: ParamHandler.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * set a parameter to a ParamSet. Parameters are propogated through that object to children, if any parameters
 * are specified for the children.
 * @param object
 * @param paramSet
 */
static void setParams(Object object, ParamSet paramSet) {
    try {
        if(object instanceof ParamHandler) {
            ((ParamHandler) object).setParams(paramSet);
        } else if(object instanceof OptionHandler) {
            ((OptionHandler) object).setOptions(paramSet.getOptions());
        } else {
            throw new IllegalArgumentException("params not settable");
        }
    } catch(Exception e) {
        throw new IllegalArgumentException(e);
    }
}