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

📄 apriori.java

📁 Java 编写的多种数据挖掘算法 包括聚类、分类、预处理等
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    if (m_outputItemSets) {      options[current++] = "-I";    }    if (getRemoveAllMissingCols()) {      options[current++] = "-R";    }    options[current++] = "-N"; options[current++] = "" + m_numRules;    options[current++] = "-T"; options[current++] = "" + m_metricType;    options[current++] = "-C"; options[current++] = "" + m_minMetric;    options[current++] = "-D"; options[current++] = "" + m_delta;    options[current++] = "-U"; options[current++] = "" + m_upperBoundMinSupport;    options[current++] = "-M"; options[current++] = "" + m_lowerBoundMinSupport;    options[current++] = "-S"; options[current++] = "" + m_significanceLevel;    if (m_car)      options[current++] = "-A";    if (m_verbose)      options[current++] = "-V";    options[current++] = "-c"; options[current++] = "" + m_classIndex;        while (current < options.length) {      options[current++] = "";    }    return options;  }  /**   * Outputs the size of all the generated sets of itemsets and the rules.   *    * @return a string representation of the model   */  public String toString() {    StringBuffer text = new StringBuffer();    if (m_Ls.size() <= 1)      return "\nNo large itemsets and rules found!\n";    text.append("\nApriori\n=======\n\n");    text.append("Minimum support: " 		+ Utils.doubleToString(m_minSupport,2) 		+ " (" + ((int)(m_minSupport * (double)m_instances.numInstances()+0.5)) 		+ " instances)"		+ '\n');    text.append("Minimum metric <");    switch(m_metricType) {    case CONFIDENCE:      text.append("confidence>: ");      break;    case LIFT:      text.append("lift>: ");      break;    case LEVERAGE:      text.append("leverage>: ");      break;    case CONVICTION:      text.append("conviction>: ");      break;    }    text.append(Utils.doubleToString(m_minMetric,2)+'\n');       if (m_significanceLevel != -1)      text.append("Significance level: "+		  Utils.doubleToString(m_significanceLevel,2)+'\n');    text.append("Number of cycles performed: " + m_cycles+'\n');    text.append("\nGenerated sets of large itemsets:\n");    if(!m_car){        for (int i = 0; i < m_Ls.size(); i++) {            text.append("\nSize of set of large itemsets L("+(i+1)+"): "+		  ((FastVector)m_Ls.elementAt(i)).size()+'\n');            if (m_outputItemSets) {                text.append("\nLarge Itemsets L("+(i+1)+"):\n");                for (int j = 0; j < ((FastVector)m_Ls.elementAt(i)).size(); j++)                    text.append(((AprioriItemSet)((FastVector)m_Ls.elementAt(i)).elementAt(j)).		      toString(m_instances)+"\n");            }        }        text.append("\nBest rules found:\n\n");        for (int i = 0; i < m_allTheRules[0].size(); i++) {            text.append(Utils.doubleToString((double)i+1, 		  (int)(Math.log(m_numRules)/Math.log(10)+1),0)+		  ". " + ((AprioriItemSet)m_allTheRules[0].elementAt(i)).		  toString(m_instances) 		  + " ==> " + ((AprioriItemSet)m_allTheRules[1].elementAt(i)).		  toString(m_instances) +"    conf:("+  		  Utils.doubleToString(((Double)m_allTheRules[2].					elementAt(i)).doubleValue(),2)+")");            if (m_metricType != CONFIDENCE || m_significanceLevel != -1) {                text.append((m_metricType == LIFT ? " <" : "")+" lift:("+  		    Utils.doubleToString(((Double)m_allTheRules[3].					  elementAt(i)).doubleValue(),2)		    +")"+(m_metricType == LIFT ? ">" : ""));                text.append((m_metricType == LEVERAGE ? " <" : "")+" lev:("+  		    Utils.doubleToString(((Double)m_allTheRules[4].					  elementAt(i)).doubleValue(),2)		    +")");                text.append(" ["+		    (int)(((Double)m_allTheRules[4].elementAt(i))			  .doubleValue() * (double)m_instances.numInstances())		    +"]"+(m_metricType == LEVERAGE ? ">" : ""));                text.append((m_metricType == CONVICTION ? " <" : "")+" conv:("+  		    Utils.doubleToString(((Double)m_allTheRules[5].					  elementAt(i)).doubleValue(),2)		    +")"+(m_metricType == CONVICTION ? ">" : ""));            }            text.append('\n');        }    }    else{        for (int i = 0; i < m_Ls.size(); i++) {            text.append("\nSize of set of large itemsets L("+(i+1)+"): "+		  ((FastVector)m_Ls.elementAt(i)).size()+'\n');            if (m_outputItemSets) {                text.append("\nLarge Itemsets L("+(i+1)+"):\n");                for (int j = 0; j < ((FastVector)m_Ls.elementAt(i)).size(); j++){                    text.append(((ItemSet)((FastVector)m_Ls.elementAt(i)).elementAt(j)).		      toString(m_instances)+"\n");                    text.append(((LabeledItemSet)((FastVector)m_Ls.elementAt(i)).elementAt(j)).m_classLabel+"  ");                    text.append(((LabeledItemSet)((FastVector)m_Ls.elementAt(i)).elementAt(j)).support()+"\n");                }            }        }        text.append("\nBest rules found:\n\n");        for (int i = 0; i < m_allTheRules[0].size(); i++) {            text.append(Utils.doubleToString((double)i+1, 					     (int)(Math.log(m_numRules)/Math.log(10)+1),0)+			". " + ((ItemSet)m_allTheRules[0].elementAt(i)).			toString(m_instances) 			+ " ==> " + ((ItemSet)m_allTheRules[1].elementAt(i)).			toString(m_onlyClass) +"    conf:("+  			Utils.doubleToString(((Double)m_allTheRules[2].					      elementAt(i)).doubleValue(),2)+")");	            text.append('\n');        }    }    return text.toString();  }     /**   * Returns the metric string for the chosen metric type   * @return a string describing the used metric for the interestingness of a class association rule   */  public String metricString() {              switch(m_metricType) {	case LIFT:	    return "lif";	case LEVERAGE:	    return "leverage"; 	case CONVICTION:	    return "conviction";        default:            return "conf";	}  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String removeAllMissingColsTipText() {    return "Remove columns with all missing values.";  }  /**   * Remove columns containing all missing values.   * @param r true if cols are to be removed.   */  public void setRemoveAllMissingCols(boolean r) {    m_removeMissingCols = r;  }  /**   * Returns whether columns containing all missing values are to be removed   * @return true if columns are to be removed.   */  public boolean getRemoveAllMissingCols() {    return m_removeMissingCols;  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String upperBoundMinSupportTipText() {    return "Upper bound for minimum support. Start iteratively decreasing "      +"minimum support from this value.";  }  /**   * Get the value of upperBoundMinSupport.   *   * @return Value of upperBoundMinSupport.   */  public double getUpperBoundMinSupport() {        return m_upperBoundMinSupport;  }    /**   * Set the value of upperBoundMinSupport.   *   * @param v  Value to assign to upperBoundMinSupport.   */  public void setUpperBoundMinSupport(double v) {        m_upperBoundMinSupport = v;  }   /**   * Sets the class index   * @param index the class index   */    public void setClassIndex(int index){            m_classIndex = index;  }    /**   * Gets the class index   * @return the index of the class attribute   */    public int getClassIndex(){            return m_classIndex;  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String classIndexTipText() {    return "Index of the class attribute. If set to -1, the last attribute is taken as class attribute.";  }  /**   * Sets class association rule mining   * @param flag if class association rules are mined, false otherwise   */    public void setCar(boolean flag){      m_car = flag;  }    /**   * Gets whether class association ruels are mined   * @return true if class association rules are mined, false otherwise   */    public boolean getCar(){      return m_car;  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String carTipText() {    return "If enabled class association rules are mined instead of (general) association rules.";  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String lowerBoundMinSupportTipText() {    return "Lower bound for minimum support.";  }  /**   * Get the value of lowerBoundMinSupport.   *   * @return Value of lowerBoundMinSupport.   */  public double getLowerBoundMinSupport() {        return m_lowerBoundMinSupport;  }    /**   * Set the value of lowerBoundMinSupport.   *   * @param v  Value to assign to lowerBoundMinSupport.   */  public void setLowerBoundMinSupport(double v) {        m_lowerBoundMinSupport = v;  }    /**   * Get the metric type   *   * @return the type of metric to use for ranking rules   */  public SelectedTag getMetricType() {    return new SelectedTag(m_metricType, TAGS_SELECTION);  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String metricTypeTipText() {    return "Set the type of metric by which to rank rules. Confidence is "      +"the proportion of the examples covered by the premise that are also "      +"covered by the consequence(Class association rules can only be mined using confidence). Lift is confidence divided by the "      +"proportion of all examples that are covered by the consequence. This "      +"is a measure of the importance of the association that is independent "      +"of support. Leverage is the proportion of additional examples covered "      +"by both the premise and consequence above those expected if the "      +"premise and consequence were independent of each other. The total "      +"number of examples that this represents is presented in brackets "      +"following the leverage. Conviction is "      +"another measure of departure from independence. Conviction is given "      +"by ";  }  /**   * Set the metric type for ranking rules   *   * @param d the type of metric   */  public void setMetricType (SelectedTag d) {        if (d.getTags() == TAGS_SELECTION) {      m_metricType = d.getSelectedTag().getID();    }    if (m_significanceLevel != -1 && m_metricType != CONFIDENCE) {      m_metricType = CONFIDENCE;    }    if (m_metricType == CONFIDENCE) {      setMinMetric(0.9);    }    if (m_metricType == LIFT || m_metricType == CONVICTION) {      setMinMetric(1.1);    }      if (m_metricType == LEVERAGE) {      setMinMetric(0.1);    }  }  /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String minMetricTipText() {    return "Minimum metric score. Consider only rules with scores higher than "      +"this value.";  }  /**   * Get the value of minConfidence.   *   * @return Value of minConfidence.   */

⌨️ 快捷键说明

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