Java Code Examples for weka.core.Utils#joinOptions()

The following examples show how to use weka.core.Utils#joinOptions() . 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: WEKAClassOption.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
public static String objectToCLIString(Object obj, Class<?> requiredType) {
	if (obj == null) {
		return "";
	}
	if (obj instanceof File) {
		return (FILE_PREFIX_STRING + ((File) obj).getPath());
	}
	if (obj instanceof String) {
		return (INMEM_PREFIX_STRING + obj);
	}
	String className = classToCLIString(obj.getClass(), requiredType);
	if (obj instanceof weka.core.OptionHandler) {
		String subOptions = Utils.joinOptions(((weka.core.OptionHandler) obj).getOptions());
		if (subOptions.length() > 0) {
			return new String(className + " " + subOptions).trim();
		}
	}
	return className;
}
 
Example 2
Source File: LWL.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 + 6];

  int current = 0;

  options[current++] = "-U"; options[current++] = "" + getWeightingKernel();
  if ( (getKNN() == 0) && m_UseAllK) {
    options[current++] = "-K"; options[current++] = "-1";
  }
  else {
    options[current++] = "-K"; options[current++] = "" + getKNN();
  }
  options[current++] = "-A";
  options[current++] = m_NNSearch.getClass().getName()+" "+Utils.joinOptions(m_NNSearch.getOptions()); 

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

  return options;
}
 
Example 3
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 4
Source File: PartitionedMultiFilter.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * returns the filter classname and the options as one string.
 *
 * @param filter	the filter to get the specs for
 * @return		the classname plus options
 */
protected String getFilterSpec(Filter filter) {
  String        result;

  if (filter == null) {
    result = "";
  }
  else {
    result  = filter.getClass().getName();
    if (filter instanceof OptionHandler)
      result += " "
        + Utils.joinOptions(((OptionHandler) filter).getOptions());
  }

  return result;
}
 
Example 5
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 6
Source File: IBk.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the current settings of IBk.
 *
 * @return an array of strings suitable for passing to setOptions()
 */
public String [] getOptions() {

  String [] options = new String [11];
  int current = 0;
  options[current++] = "-K"; options[current++] = "" + getKNN();
  options[current++] = "-W"; options[current++] = "" + m_WindowSize;
  if (getCrossValidate()) {
    options[current++] = "-X";
  }
  if (getMeanSquared()) {
    options[current++] = "-E";
  }
  if (m_DistanceWeighting == WEIGHT_INVERSE) {
    options[current++] = "-I";
  } else if (m_DistanceWeighting == WEIGHT_SIMILARITY) {
    options[current++] = "-F";
  }

  options[current++] = "-A";
  options[current++] = m_NNSearch.getClass().getName()+" "+Utils.joinOptions(m_NNSearch.getOptions()); 
  
  while (current < options.length) {
    options[current++] = "";
  }
  
  return options;
}
 
Example 7
Source File: CVParameterSelection.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Returns description of the cross-validated classifier.
  *
  * @return description of the cross-validated classifier as a string
  */
 public String toString() {

   if (m_InitOptions == null)
     return "CVParameterSelection: No model built yet.";

   String result = "Cross-validated Parameter selection.\n"
   + "Classifier: " + m_Classifier.getClass().getName() + "\n";
   try {
     for (int i = 0; i < m_CVParams.size(); i++) {
CVParameter cvParam = (CVParameter)m_CVParams.elementAt(i);
result += "Cross-validation Parameter: '-" 
  + cvParam.m_ParamChar + "'"
  + " ranged from " + cvParam.m_Lower 
  + " to ";
switch ((int)(cvParam.m_Lower - cvParam.m_Upper + 0.5)) {
case 1:
  result += m_NumAttributes;
  break;
case 2:
  result += m_TrainFoldSize;
  break;
default:
  result += cvParam.m_Upper;
  break;
}
result += " with " + cvParam.m_Steps + " steps\n";
     }
   } catch (Exception ex) {
     result += ex.getMessage();
   }
   result += "Classifier Options: "
     + Utils.joinOptions(m_BestClassifierOptions)
     + "\n\n" + m_Classifier.toString();
   return result;
 }
 
Example 8
Source File: CVParameterSelection.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns graph describing the classifier (if possible).
 *
 * @return the graph of the classifier in dotty format
 * @throws Exception if the classifier cannot be graphed
 */
public String graph() throws Exception {
  
  if (m_Classifier instanceof Drawable)
    return ((Drawable)m_Classifier).graph();
  else throw new Exception("Classifier: " + 
	     m_Classifier.getClass().getName() + " " +
	     Utils.joinOptions(m_BestClassifierOptions)
	     + " cannot be graphed");
}
 
Example 9
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 10
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 11
Source File: FilteredSubsetEval.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Get the filter + options as a string
  *
  * @return a String containing the name of the filter + any options
  */
 protected String getFilterSpec() {
   Filter c = getFilter();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example 12
Source File: CostSensitiveASEvaluation.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the evaluator specification string, which contains the class name of
  * the evaluator and any options to the evaluator
  *
  * @return the evaluator string.
  */
 protected String getEvaluatorSpec() {
   
   ASEvaluation ase = getEvaluator();
   if (ase instanceof OptionHandler) {
     return ase.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)ase).getOptions());
   }
   return ase.getClass().getName();
 }
 
Example 13
Source File: FilteredAttributeEval.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() {
  AttributeEvaluator a = m_evaluator;
  if (a instanceof OptionHandler) {
    return a.getClass().getName() + " "
      + Utils.joinOptions(((OptionHandler)a).getOptions());
  }
  return a.getClass().getName();
}
 
Example 14
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 15
Source File: AssociationRules.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new AssociationRules.
 * 
 * @param rules the list of rules.
 * @param producer the scheme that produced the rules.
 */
public AssociationRules(List<AssociationRule> rules, Object producer) {
  String producerString = producer.getClass().getName();
  if (producerString.startsWith("weka.associations.")) {
    producerString = producerString.substring("weka.associations.".length());
  }    
  
  if (producer instanceof OptionHandler) {
    String [] o = ((OptionHandler) producer).getOptions();
    producerString += " " + Utils.joinOptions(o);
  }
  
  m_rules = rules;
  m_producer = producerString;
}
 
Example 16
Source File: FilteredClusterer.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() {
  String	result;
  Filter 	filter;
  
  filter = getFilter();
  result = filter.getClass().getName();
  
  if (filter instanceof OptionHandler)
    result += " " + Utils.joinOptions(((OptionHandler) filter).getOptions());
  
  return result;
}
 
Example 17
Source File: CollectiveRandomizableSingleClassifierEnhancer.java    From collective-classification-weka-package with GNU General Public License v3.0 5 votes vote down vote up
/**
 * returns the specification of the given object (class, options if an 
 * instance of OptionHandler)
 *
 * @param o		the object to get the specs as string
 * @return		the specification string
 */
protected String getSpecification(Object o) {
  String      result;

  result = o.getClass().getName();
  if (o instanceof OptionHandler)
    result += " " + Utils.joinOptions(((OptionHandler) o).getOptions());

  return result.trim();
}
 
Example 18
Source File: XMeans.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the KDTree specification string, which contains the class name of
  * the KDTree class and any options to the KDTree.
  *
  * @return the KDTree string.
  */
 protected String getKDTreeSpec() {
   
   KDTree c = getKDTree();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example 19
Source File: AddCluster.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the clusterer specification string, which contains the class name of
  * the clusterer and any options to the clusterer.
  *
  * @return the clusterer string.
  */
 protected String getClustererSpec() {
   Clusterer c = getClusterer();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
Example 20
Source File: AttributeSelectedClassifier.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();
 }