⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridsearch.java

📁 代码是一个分类器的实现,其中使用了部分weka的源代码。可以将项目导入eclipse运行
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   *  Available parameters:   *   BASE   *   MIN   *   MAX   *   STEP   *   I - the current iteration value   *   (from 'FROM' to 'TO' with stepsize 'STEP')   *  (default: 'pow(BASE,I)')</pre>   *    * <pre> -extend-grid   *  Whether the grid can be extended.   *  (default: no)</pre>   *    * <pre> -max-grid-extensions &lt;num&gt;   *  The maximum number of grid extensions (-1 is unlimited).   *  (default: 3)</pre>   *    * <pre> -sample-size &lt;num&gt;   *  The size (in percent) of the sample to search the inital grid with.   *  (default: 100)</pre>   *    * <pre> -traversal &lt;ROW-WISE|COLUMN-WISE&gt;   *  The type of traversal for the grid.   *  (default: COLUMN-WISE)</pre>   *    * <pre> -log-file &lt;filename&gt;   *  The log file to log the messages to.   *  (default: none)</pre>   *    * <pre> -S &lt;num&gt;   *  Random number seed.   *  (default 1)</pre>   *    * <pre> -D   *  If set, classifier is run in debug mode and   *  may output additional info to the console</pre>   *    * <pre> -W   *  Full name of base classifier.   *  (default: weka.classifiers.functions.LinearRegression)</pre>   *    * <pre>    * Options specific to classifier weka.classifiers.functions.LinearRegression:   * </pre>   *    * <pre> -D   *  Produce debugging output.   *  (default no debugging output)</pre>   *    * <pre> -S &lt;number of selection method&gt;   *  Set the attribute selection method to use. 1 = None, 2 = Greedy.   *  (default 0 = M5' method)</pre>   *    * <pre> -C   *  Do not try to eliminate colinear attributes.   * </pre>   *    * <pre> -R &lt;double&gt;   *  Set ridge parameter (default 1.0e-8).   * </pre>   *    * <pre>    * Options specific to filter weka.filters.supervised.attribute.PLSFilter ('-filter'):   * </pre>   *    * <pre> -D   *  Turns on output of debugging information.</pre>   *    * <pre> -C &lt;num&gt;   *  The number of components to compute.   *  (default: 20)</pre>   *    * <pre> -U   *  Updates the class attribute as well.   *  (default: off)</pre>   *    * <pre> -M   *  Turns replacing of missing values on.   *  (default: off)</pre>   *    * <pre> -A &lt;SIMPLS|PLS1&gt;   *  The algorithm to use.   *  (default: PLS1)</pre>   *    * <pre> -P &lt;none|center|standardize&gt;   *  The type of preprocessing that is applied to the data.   *  (default: center)</pre>   *    <!-- options-end -->   *   * @param options	the options to use   * @throws Exception	if setting of options fails   */  public void setOptions(String[] options) throws Exception {    String	tmpStr;    String[]	tmpOptions;    tmpStr = Utils.getOption('E', options);    if (tmpStr.length() != 0)      setEvaluation(new SelectedTag(tmpStr, TAGS_EVALUATION));    else      setEvaluation(new SelectedTag(EVALUATION_CC, TAGS_EVALUATION));        tmpStr = Utils.getOption("y-property", options);    if (tmpStr.length() != 0)      setYProperty(tmpStr);    else      setYProperty(PREFIX_CLASSIFIER + "ridge");        tmpStr = Utils.getOption("y-min", options);    if (tmpStr.length() != 0)      setYMin(Double.parseDouble(tmpStr));    else      setYMin(-10);        tmpStr = Utils.getOption("y-max", options);    if (tmpStr.length() != 0)      setYMax(Double.parseDouble(tmpStr));    else      setYMax(10);        tmpStr = Utils.getOption("y-step", options);    if (tmpStr.length() != 0)      setYStep(Double.parseDouble(tmpStr));    else      setYStep(1);        tmpStr = Utils.getOption("y-base", options);    if (tmpStr.length() != 0)      setYBase(Double.parseDouble(tmpStr));    else      setYBase(10);        tmpStr = Utils.getOption("y-expression", options);    if (tmpStr.length() != 0)      setYExpression(tmpStr);    else      setYExpression("pow(BASE,I)");        tmpStr     = Utils.getOption("filter", options);    tmpOptions = Utils.splitOptions(tmpStr);    if (tmpOptions.length != 0) {      tmpStr        = tmpOptions[0];      tmpOptions[0] = "";      setFilter((Filter) Utils.forName(Filter.class, tmpStr, tmpOptions));    }        tmpStr = Utils.getOption("x-property", options);    if (tmpStr.length() != 0)      setXProperty(tmpStr);    else      setXProperty(PREFIX_FILTER + "filters[0].kernel.gamma");        tmpStr = Utils.getOption("x-min", options);    if (tmpStr.length() != 0)      setXMin(Double.parseDouble(tmpStr));    else      setXMin(-10);        tmpStr = Utils.getOption("x-max", options);    if (tmpStr.length() != 0)      setXMax(Double.parseDouble(tmpStr));    else      setXMax(10);        tmpStr = Utils.getOption("x-step", options);    if (tmpStr.length() != 0)      setXStep(Double.parseDouble(tmpStr));    else      setXStep(1);        tmpStr = Utils.getOption("x-base", options);    if (tmpStr.length() != 0)      setXBase(Double.parseDouble(tmpStr));    else      setXBase(10);        tmpStr = Utils.getOption("x-expression", options);    if (tmpStr.length() != 0)      setXExpression(tmpStr);    else      setXExpression("pow(BASE,I)");        setGridIsExtendable(Utils.getFlag("extend-grid", options));    if (getGridIsExtendable()) {      tmpStr = Utils.getOption("max-grid-extensions", options);      if (tmpStr.length() != 0)        setMaxGridExtensions(Integer.parseInt(tmpStr));      else        setMaxGridExtensions(3);    }        tmpStr = Utils.getOption("sample-size", options);    if (tmpStr.length() != 0)      setSampleSizePercent(Double.parseDouble(tmpStr));    else      setSampleSizePercent(100);        tmpStr = Utils.getOption("traversal", options);    if (tmpStr.length() != 0)      setTraversal(new SelectedTag(tmpStr, TAGS_TRAVERSAL));    else      setTraversal(new SelectedTag(TRAVERSAL_BY_ROW, TAGS_TRAVERSAL));        tmpStr = Utils.getOption("log-file", options);    if (tmpStr.length() != 0)      setLogFile(new File(tmpStr));    else      setLogFile(new File(System.getProperty("user.dir")));        super.setOptions(options);  }  /**   * Set the base learner.   *   * @param newClassifier 	the classifier to use.   */  public void setClassifier(Classifier newClassifier) {    boolean	numeric;    boolean	nominal;        Capabilities cap = newClassifier.getCapabilities();    numeric =    cap.handles(Capability.NUMERIC_CLASS)     	      || cap.hasDependency(Capability.NUMERIC_CLASS);        nominal =    cap.handles(Capability.NOMINAL_CLASS)              || cap.hasDependency(Capability.NOMINAL_CLASS)              || cap.handles(Capability.BINARY_CLASS)              || cap.hasDependency(Capability.BINARY_CLASS)              || cap.handles(Capability.UNARY_CLASS)              || cap.hasDependency(Capability.UNARY_CLASS);        if ((m_Evaluation == EVALUATION_CC) && !numeric)      throw new IllegalArgumentException(	  "Classifier needs to handle numeric class for chosen type of evaluation!");    if ((m_Evaluation == EVALUATION_ACC) && !nominal)      throw new IllegalArgumentException(	  "Classifier needs to handle nominal class for chosen type of evaluation!");        super.setClassifier(newClassifier);        try {      m_BestClassifier = Classifier.makeCopy(m_Classifier);    }    catch (Exception e) {      e.printStackTrace();    }  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String filterTipText() {    return "The filter to be used (only used for setup).";  }  /**   * Set the kernel filter (only used for setup).   *   * @param value	the kernel filter.   */  public void setFilter(Filter value) {    m_Filter = value;    try {      m_BestFilter = Filter.makeCopy(m_Filter);    }    catch (Exception e) {      e.printStackTrace();    }  }  /**   * Get the kernel filter.   *   * @return 		the kernel filter   */  public Filter getFilter() {    return m_Filter;  }  /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String evaluationTipText() {    return         "Sets the criterion for evaluating the classifier performance and "      + "choosing the best one.";  }  /**   * Sets the criterion to use for evaluating the classifier performance.    *   * @param value 	.the evaluation criterion   */  public void setEvaluation(SelectedTag value) {    if (value.getTags() == TAGS_EVALUATION) {      m_Evaluation = value.getSelectedTag().getID();    }  }  /**   * Gets the criterion used for evaluating the classifier performance.    *   * @return 		the current evaluation criterion.   */  public SelectedTag getEvaluation() {    return new SelectedTag(m_Evaluation, TAGS_EVALUATION);  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String YPropertyTipText() {    return "The Y property to test (normally the classifier).";  }  /**   * Get the Y property (normally the classifier).   *   * @return 		Value of the property.   */  public String getYProperty() {    return m_Y_Property;  }    /**   * Set the Y property (normally the classifier).   *   * @param value 	the Y property.   */  public void setYProperty(String value) {    m_Y_Property = value;  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String YMinTipText() {    return "The minimum of Y (normally the classifier).";  }  /**   * Get the value of the minimum of Y.   *   * @return 		Value of the minimum of Y.   */  public double getYMin() {    return m_Y_Min;  }    /**   * Set the value of the minimum of Y.   *   * @param value 	Value to use as minimum of Y.   */  public void setYMin(double value) {    m_Y_Min = value;  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String YMaxTipText() {    return "The maximum of Y.";  }  /**   * Get the value of the Maximum of Y.   *   * @return 		Value of the Maximum of Y.   */  public double getYMax() {    return m_Y_Max;  }    /**   * Set the value of the Maximum of Y.   *   * @param value 	Value to use as Maximum of Y.   */  public void setYMax(double value) {    m_Y_Max = value;  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String YStepTipText() {    return "The step size of Y.";  }  /**   * Get the value of the step size for Y.   *   * @return 		Value of the step size for Y.   */  public double getYStep() {    return m_Y_Step;  }    /**   * Set the value of the step size for Y.   *   * @param value 	Value to use as the step size for Y.   */  public void setYStep(double value) {    m_Y_Step = value;  }    /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String YBaseTipText() {    return "The base of Y.";  }  /**   * Get the value of the base for Y.   *   * @return 		Value of the base for Y.   */  public double getYBase() {    return m_Y_Base;  }    /**   * Set the value of the base for Y.   *   * @param value Value to use as the base for Y.   */  public void setYBase(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -