📄 simplelogistic.java
字号:
options[current++] = "-I";
options[current++] = ""+getNumBoostingIterations();
if (!getUseCrossValidation()) {
options[current++] = "-S";
}
if (getErrorOnProbabilities()) {
options[current++] = "-P";
}
options[current++] = "-M";
options[current++] = ""+getMaxBoostingIterations();
options[current++] = "-H";
options[current++] = ""+getHeuristicStop();
while (current < options.length) {
options[current++] = "";
}
return options;
}
/**
* Get the value of numBoostingIterations.
*/
public int getNumBoostingIterations(){
return m_numBoostingIterations;
}
/**
* Get the value of useCrossValidation.
*/
public boolean getUseCrossValidation(){
return m_useCrossValidation;
}
/**
* Get the value of errorOnProbabilities.
*/
public boolean getErrorOnProbabilities(){
return m_errorOnProbabilities;
}
/**
* Get the value of maxBoostingIterations.
*/
public int getMaxBoostingIterations(){
return m_maxBoostingIterations;
}
/**
* Get the value of heuristicStop.
*/
public int getHeuristicStop(){
return m_heuristicStop;
}
/**
* Set the value of numBoostingIterations.
*/
public void setNumBoostingIterations(int n){
m_numBoostingIterations = n;
}
/**
* Set the value of useCrossValidation.
*/
public void setUseCrossValidation(boolean l){
m_useCrossValidation = l;
}
/**
* Set the value of errorOnProbabilities.
*/
public void setErrorOnProbabilities(boolean l){
m_errorOnProbabilities = l;
}
/**
* Set the value of maxBoostingIterations.
*/
public void setMaxBoostingIterations(int n){
m_maxBoostingIterations = n;
}
/**
* Set the value of heuristicStop.
*/
public void setHeuristicStop(int n){
if (n == 0) m_heuristicStop = m_maxBoostingIterations; else m_heuristicStop = n;
}
/**
* Get the number of LogitBoost iterations performed (= the number of regression functions fit by LogitBoost).
*/
public int getNumRegressions(){
return m_boostedModel.getNumRegressions();
}
/**
* Returns a description of the logistic model (attributes/coefficients).
*/
public String toString(){
if (m_boostedModel == null) return "No model built";
return "SimpleLogistic:\n" + m_boostedModel.toString();
}
/**
* Returns the fraction of all attributes in the data that are used in the logistic model (in percent).
* An attribute is used in the model if it is used in any of the models for the different classes.
*/
public double measureAttributesUsed(){
return m_boostedModel.percentAttributesUsed();
}
/**
* Returns an enumeration of the additional measure names
* @return an enumeration of the measure names
*/
public Enumeration enumerateMeasures() {
Vector newVector = new Vector(3);
newVector.addElement("measureAttributesUsed");
newVector.addElement("measureNumIterations");
return newVector.elements();
}
/**
* Returns the value of the named measure
* @param additionalMeasureName the name of the measure to query for its value
* @return the value of the named measure
* @exception IllegalArgumentException if the named measure is not supported
*/
public double getMeasure(String additionalMeasureName) {
if (additionalMeasureName.compareToIgnoreCase("measureAttributesUsed") == 0) {
return measureAttributesUsed();
} else if(additionalMeasureName.compareToIgnoreCase("measureNumIterations") == 0){
return getNumRegressions();
} else {
throw new IllegalArgumentException(additionalMeasureName
+ " not supported (SimpleLogistic)");
}
}
/**
* Returns a string describing classifier
* @return a description suitable for
* displaying in the explorer/experimenter gui
*/
public String globalInfo() {
return "Classifier for building linear logistic regression models. LogitBoost with simple regression "
+"functions as base learners is used for fitting the logistic models. The optimal number of LogitBoost "
+"iterations to perform is cross-validated, which leads to automatic attribute selection. "
+"For more information see: N.Landwehr, M.Hall, E. Frank 'Logistic Model Trees' (ECML 2003).";
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String numBoostingIterationsTipText() {
return "Set fixed number of iterations for LogitBoost. If >= 0, this sets the number of LogitBoost iterations "
+"to perform. If < 0, the number is cross-validated or a stopping criterion on the training set is used "
+"(depending on the value of useCrossValidation).";
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String useCrossValidationTipText() {
return "Sets whether the number of LogitBoost iterations is to be cross-validated or the stopping criterion "
+"on the training set should be used. If not set (and no fixed number of iterations was given), "
+"the number of LogitBoost iterations is used that minimizes the error on the training set "
+"(misclassification error or error on probabilities depending on errorOnProbabilities).";
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String errorOnProbabilitiesTipText() {
return "Use error on the probabilties as error measure when determining the best number of LogitBoost iterations. "
+"If set, the number of LogitBoost iterations is chosen that minimizes the root mean squared error "
+"(either on the training set or in the cross-validation, depending on useCrossValidation).";
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String maxBoostingIterationsTipText() {
return "Sets the maximum number of iterations for LogitBoost. Default value is 500, for very small/large "
+"datasets a lower/higher value might be preferable.";
}
/**
* Returns the tip text for this property
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String heuristicStopTipText() {
return "If heuristicStop > 0, the heuristic for greedy stopping while cross-validating the number of "
+"LogitBoost iterations is enabled. This means LogitBoost is stopped if no new error minimum "
+"has been reached in the last heuristicStop iterations. It is recommended to use this heuristic, "
+"it gives a large speed-up especially on small datasets. The default value is 50.";
}
/**
* Main method for testing this class
*
* @param String options
*/
public static void main(String[] argv) {
try {
System.out.println(Evaluation.evaluateModel(new SimpleLogistic(), argv));
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -