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

📄 libsvm.java

📁 Java 编写的多种数据挖掘算法 包括聚类、分类、预处理等
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      setKernelType(          new SelectedTag(Integer.parseInt(tmpStr), TAGS_KERNELTYPE));    else      setKernelType(          new SelectedTag(KERNELTYPE_RBF, TAGS_KERNELTYPE));        tmpStr = Utils.getOption('D', options);    if (tmpStr.length() != 0)      setDegree(Integer.parseInt(tmpStr));    else      setDegree(3);        tmpStr = Utils.getOption('G', options);    if (tmpStr.length() != 0)      setGamma(Double.parseDouble(tmpStr));    else      setGamma(0);        tmpStr = Utils.getOption('R', options);    if (tmpStr.length() != 0)      setCoef0(Double.parseDouble(tmpStr));    else      setCoef0(0);        tmpStr = Utils.getOption('N', options);    if (tmpStr.length() != 0)      setNu(Double.parseDouble(tmpStr));    else      setNu(0.5);        tmpStr = Utils.getOption('M', options);    if (tmpStr.length() != 0)      setCacheSize(Double.parseDouble(tmpStr));    else      setCacheSize(40);        tmpStr = Utils.getOption('C', options);    if (tmpStr.length() != 0)      setCost(Double.parseDouble(tmpStr));    else      setCost(1);        tmpStr = Utils.getOption('E', options);    if (tmpStr.length() != 0)      setEps(Double.parseDouble(tmpStr));    else      setEps(1e-3);        setNormalize(Utils.getFlag('Z', options));        tmpStr = Utils.getOption('P', options);    if (tmpStr.length() != 0)      setLoss(Double.parseDouble(tmpStr));    else      setLoss(0.1);        setShrinking(!Utils.getFlag('H', options));        setWeights(Utils.getOption('W', options));  }    /**   * Returns the current options   *    * @return            the current setup   */  public String[] getOptions() {    Vector        result;        result  = new Vector();        result.add("-S");    result.add("" + m_SVMType);        result.add("-K");    result.add("" + m_KernelType);        result.add("-D");    result.add("" + getDegree());        result.add("-G");    result.add("" + getGamma());        result.add("-R");    result.add("" + getCoef0());        result.add("-N");    result.add("" + getNu());        result.add("-M");    result.add("" + getCacheSize());        result.add("-C");    result.add("" + getCost());        result.add("-E");    result.add("" + getEps());        result.add("-P");    result.add("" + getLoss());        if (!getShrinking())      result.add("-H");        if (getNormalize())      result.add("-Z");        if (getWeights().length() != 0) {      result.add("-W");      result.add("" + getWeights());    }        return (String[]) result.toArray(new String[result.size()]);  }    /**   * returns whether the libsvm classes are present or not, i.e. whether the    * classes are in the classpath or not   *   * @return whether the libsvm classes are available   */  public static boolean isPresent() {    return m_Present;  }    /**   * Sets type of SVM (default SVMTYPE_C_SVC)   *    * @param value       the type of the SVM   */  public void setSVMType(SelectedTag value) {    if (value.getTags() == TAGS_SVMTYPE)      m_SVMType = value.getSelectedTag().getID();  }    /**   * Gets type of SVM   *    * @return            the type of the SVM   */  public SelectedTag getSVMType() {    return new SelectedTag(m_SVMType, TAGS_SVMTYPE);  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String SVMTypeTipText() {    return "The type of SVM to use.";  }    /**   * Sets type of kernel function (default KERNELTYPE_RBF)   *    * @param value       the kernel type   */  public void setKernelType(SelectedTag value) {    if (value.getTags() == TAGS_KERNELTYPE)      m_KernelType = value.getSelectedTag().getID();  }    /**   * Gets type of kernel function   *    * @return            the kernel type   */  public SelectedTag getKernelType() {    return new SelectedTag(m_KernelType, TAGS_KERNELTYPE);  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String kernelTypeTipText() {    return "The type of kernel to use";  }    /**   * Sets the degree of the kernel   *    * @param value       the degree of the kernel   */  public void setDegree(int value) {    m_Degree = value;  }    /**   * Gets the degree of the kernel   *    * @return            the degree of the kernel   */  public int getDegree() {    return m_Degree;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String degreeTipText() {    return "The degree of the kernel.";  }    /**   * Sets gamma (default = 1/no of attributes)   *    * @param value       the gamma value   */  public void setGamma(double value) {    m_Gamma = value;  }    /**   * Gets gamma   *    * @return            the current gamma   */  public double getGamma() {    return m_Gamma;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String gammaTipText() {    return "The gamma to use, if 0 then 1/max_index is used.";  }    /**   * Sets coef (default 0)   *    * @param value       the coef   */  public void setCoef0(double value) {    m_Coef0 = value;  }    /**   * Gets coef   *    * @return            the coef   */  public double getCoef0() {    return m_Coef0;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String coef0TipText() {    return "The coefficient to use.";  }    /**   * Sets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)   *    * @param value       the new nu value   */  public void setNu(double value) {    m_nu = value;  }    /**   * Gets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)   *    * @return            the current nu value   */  public double getNu() {    return m_nu;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String nuTipText() {    return "The value of nu for nu-SVC, one-class SVM and nu-SVR.";  }    /**   * Sets cache memory size in MB (default 40)   *    * @param value       the memory size in MB   */  public void setCacheSize(double value) {    m_CacheSize = value;  }    /**   * Gets cache memory size in MB   *    * @return            the memory size in MB   */  public double getCacheSize() {    return m_CacheSize;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String cacheSizeTipText() {    return "The cache size in MB.";  }    /**   * Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)   *    * @param value       the cost value   */  public void setCost(double value) {    m_Cost = value;  }    /**   * Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVR   *    * @return            the cost value   */  public double getCost() {    return m_Cost;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String costTipText() {    return "The cost parameter C for C-SVC, epsilon-SVR and nu-SVR.";  }    /**   * Sets tolerance of termination criterion (default 0.001)   *    * @param value       the tolerance   */  public void setEps(double value) {    m_eps = value;  }    /**   * Gets tolerance of termination criterion   *    * @return            the current tolerance   */  public double getEps() {    return m_eps;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String epsTipText() {    return "The tolerance of the termination criterion.";  }    /**   * Sets the epsilon in loss function of epsilon-SVR (default 0.1)   *    * @param value       the loss epsilon   */  public void setLoss(double value) {    m_Loss = value;  }    /**   * Gets the epsilon in loss function of epsilon-SVR   *    * @return            the loss epsilon   */  public double getLoss() {    return m_Loss;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String lossTipText() {    return "The epsilon for the loss function in epsilon-SVR.";  }    /**   * whether to use the shrinking heuristics   *    * @param value       true uses shrinking   */  public void setShrinking(boolean value) {    m_Shrinking = value;  }    /**   * whether to use the shrinking heuristics   *    * @return            true, if shrinking is used   */  public boolean getShrinking() {    return m_Shrinking;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String shrinkingTipText() {    return "Whether to use the shrinking heuristic.";  }    /**   * whether to normalize input data   *    * @param value       whether to normalize the data   */  public void setNormalize(boolean value) {    m_Normalize = value;  }    /**   * whether to normalize input data   *    * @return            true, if the data is normalized   */  public boolean getNormalize() {    return m_Normalize;  }    /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String normalizeTipText() {    return "Whether to normalize the data.";  }    /**   * Sets the parameters C of class i to weight[i]*C, for C-SVC (default 1).   * Blank separated list of doubles.   *    * @param weightsStr          the weights (doubles, separated by blanks)   */  public void setWeights(String weightsStr) {    StringTokenizer       tok;    int                   i;        tok           = new StringTokenizer(weightsStr, " ");    m_Weight      = new double[tok.countTokens()];    m_WeightLabel = new int[tok.countTokens()];        if (m_Weight.length == 0)      System.out.println(          "Zero Weights processed. Default weights will be used");        for (i = 0; i < m_Weight.length; i++) {      m_Weight[i] = Double.parseDouble(tok.nextToken());      if (i == 0)        m_WeightLabel[i] = -1;  // label of first class      else        m_WeightLabel[i] = i;

⌨️ 快捷键说明

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