📄 racedincrementallogitboost.java
字号:
} setClassifier(Classifier.forName(classifierName, Utils.partitionOptions(options))); } /** * Gets the current settings of the Classifier. * * @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 + 15]; int current = 0; if (getDebug()) { options[current++] = "-D"; } if (getUseResampling()) { options[current++] = "-Q"; } if (getSeed() != 1) { options[current++] = "-S"; options[current++] = "" + getSeed(); } options[current++] = "-C"; options[current++] = "" + getMinChunkSize(); options[current++] = "-M"; options[current++] = "" + getMaxChunkSize(); options[current++] = "-V"; options[current++] = "" + getValidationChunkSize(); options[current++] = "-P"; options[current++] = "" + m_PruningType; 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; } /** * @return a description of the classifier suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "Classifier for incremental learning of large datasets by way of racing logit-boosted committees."; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String classifierTipText() { return "Sets the base classifier to boost. If not capable of handling weighted instances then resampling will be used."; } /** * Set the classifier for boosting. The learner should be able to * handle numeric class attributes. * * @param newClassifier the Classifier to use. */ public void setClassifier(Classifier newClassifier) { m_Classifier = newClassifier; } /** * Get the classifier used as the classifier * * @return the classifier used as the classifier */ public Classifier getClassifier() { return m_Classifier; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String minChunkSizeTipText() { return "The minimum number of instances to train the base learner with."; } /** * Set the minimum chunk size * * @param chunkSize */ public void setMinChunkSize(int chunkSize) { m_minChunkSize = chunkSize; } /** * Get the minimum chunk size * * @return the chunk size */ public int getMinChunkSize() { return m_minChunkSize; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String maxChunkSizeTipText() { return "The maximum number of instances to train the base learner with. The chunk sizes used will start at minChunkSize and grow twice as large for as many times as they are less than or equal to the maximum size."; } /** * Set the maximum chunk size * * @param chunkSize */ public void setMaxChunkSize(int chunkSize) { m_maxChunkSize = chunkSize; } /** * Get the maximum chunk size * * @return the chunk size */ public int getMaxChunkSize() { return m_maxChunkSize; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String validationChunkSizeTipText() { return "The number of instances to hold out for validation. These instances will be taken from the beginning of the stream, so learning will not start until these instances have been consumed first."; } /** * Set the validation chunk size * * @param chunkSize */ public void setValidationChunkSize(int chunkSize) { m_validationChunkSize = chunkSize; } /** * Get the validation chunk size * * @return the chunk size */ public int getValidationChunkSize() { return m_validationChunkSize; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String pruningTypeTipText() { return "The pruning method to use within each committee. Log likelihood pruning will discard new models if they have a negative effect on the log likelihood of the validation data."; } /** * Set the pruning type * * @param pruneType */ public void setPruningType(SelectedTag pruneType) { if (pruneType.getTags() == TAGS_PRUNETYPE) { m_PruningType = pruneType.getSelectedTag().getID(); } } /** * Get the pruning type * * @return the type */ public SelectedTag getPruningType() { return new SelectedTag(m_PruningType, TAGS_PRUNETYPE); } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String debugTipText() { return "Whether debugging output should be sent to the terminal."; } /** * Set debugging mode * * @param debug true if debug output should be printed */ public void setDebug(boolean debug) { m_Debug = debug; } /** * Get whether debugging is turned on * * @return true if debugging output is on */ public boolean getDebug() { return m_Debug; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String useResamplingTipText() { return "Force the use of resampling data rather than using the weight-handling capabilities of the base classifier. Resampling is always used if the base classifier cannot handle weighted instances."; } /** * Set resampling mode * * @param resampling true if resampling should be done */ public void setUseResampling(boolean r) { m_UseResampling = r; } /** * Get whether resampling is turned on * * @return true if resampling output is on */ public boolean getUseResampling() { return m_UseResampling; } /** * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String seedTipText() { return "Random seed used for resampling the data."; } /** * Set seed for resampling. * * @param seed the seed for resampling */ public void setSeed(int seed) { m_Seed = seed; } /** * Get seed for resampling. * * @return the seed for resampling */ public int getSeed() { return m_Seed; } /** * Get the best committee chunk size */ public int getBestCommitteeChunkSize() { if (m_bestCommittee != null) { return m_bestCommittee.chunkSize(); } else return 0; } /** * Get the number of members in the best committee */ public int getBestCommitteeSize() { if (m_bestCommittee != null) { return m_bestCommittee.committeeSize(); } else return 0; } /** * Get the best committee's error on the validation data */ public double getBestCommitteeErrorEstimate() { if (m_bestCommittee != null) { try { return m_bestCommittee.validationError() * 100.0; } catch (Exception e) { System.err.println(e.getMessage()); return 100.0; } } else return 100.0; } /** * Get the best committee's log likelihood on the validation data */ public double getBestCommitteeLLEstimate() { if (m_bestCommittee != null) { try { return m_bestCommittee.logLikelihood(); } catch (Exception e) { System.err.println(e.getMessage()); return Double.MAX_VALUE; } } else return Double.MAX_VALUE; } /** * Returns description of the boosted classifier. * * @return description of the boosted classifier as a string */ public String toString() { if (m_bestCommittee != null) { return m_bestCommittee.toString(); } else { if ((m_validationSetChanged || m_zeroR == null) && m_validationSet != null && m_validationSet.numInstances() > 0) { m_zeroR = new ZeroR(); try { m_zeroR.buildClassifier(m_validationSet); } catch (Exception e) {} m_validationSetChanged = false; } if (m_zeroR != null) { return ("RacedIncrementalLogitBoost: insufficient data to build model, resorting to ZeroR:\n\n" + m_zeroR.toString()); } else return ("RacedIncrementalLogitBoost: no model built yet."); } } /** * Main method for this class. */ public static void main(String[] argv) { try { System.out.println(Evaluation.evaluateModel(new RacedIncrementalLogitBoost(), argv)); } catch (Exception e) { e.printStackTrace(); System.err.println(e.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -