noisecurvecrossvalidationresultproducer.java

来自「wekaUT是 university texas austin 开发的基于wek」· Java 代码 · 共 1,346 行 · 第 1/3 页

JAVA
1,346
字号
     */    protected int plotPoint(int i) {	// If i beyond number of given plot points return a value greater than maximum training size	if (i >= m_PlotPoints.length)	    return maxTrainSize() + 1;	double point = m_PlotPoints[i];	// If plot point is an integer (other than a non-initial 1)	// treat it as a specific number of examples	if (isInteger(point) && !(Utils.eq(point, 1.0) && i!=0))	    return (int)point;	else	    // Otherwise, treat it as a percentage of the full set	    return (int)Math.round(point * maxTrainSize());    }    /** Return true if the given double represents an integer value */    protected static boolean isInteger(double val) {	return Utils.eq(Math.floor(val), Math.ceil(val));    }    /**     * Gets the names of each of the columns produced for a single run.     * This method should really be static.     *     * @@return an array containing the name of each column     */    public String [] getKeyNames() {	String [] keyNames = m_SplitEvaluator.getKeyNames();	// Add in the names of our extra key fields	int numExtraKeys;	numExtraKeys = 5;	String [] newKeyNames = new String [keyNames.length + numExtraKeys];	newKeyNames[0] = DATASET_FIELD_NAME;	newKeyNames[1] = RUN_FIELD_NAME;	newKeyNames[2] = FOLD_FIELD_NAME;	newKeyNames[3] = STEP_FIELD_NAME;	newKeyNames[4] = NOISE_FIELD_NAME;	System.arraycopy(keyNames, 0, newKeyNames, numExtraKeys, keyNames.length);	return newKeyNames;    }    /**     * Gets the data types of each of the columns produced for a single run.     * This method should really be static.     *     * @@return an array containing objects of the type of each column. The      * objects should be Strings, or Doubles.     */    public Object [] getKeyTypes() {	Object [] keyTypes = m_SplitEvaluator.getKeyTypes();	int numExtraKeys;	numExtraKeys = 5;	// Add in the types of our extra fields	Object [] newKeyTypes = new String [keyTypes.length + numExtraKeys];	newKeyTypes[0] = new String();	newKeyTypes[1] = new String();	newKeyTypes[2] = new String();	newKeyTypes[3] = new String();	newKeyTypes[4] = new String();	System.arraycopy(keyTypes, 0, newKeyTypes, numExtraKeys, keyTypes.length);	return newKeyTypes;    }    /**     * Gets the names of each of the columns produced for a single run.     * This method should really be static.     *     * @@return an array containing the name of each column     */    public String [] getResultNames() {	String [] resultNames = m_SplitEvaluator.getResultNames();	// Add in the names of our extra Result fields	String [] newResultNames = new String [resultNames.length + 1];	newResultNames[0] = TIMESTAMP_FIELD_NAME;	System.arraycopy(resultNames, 0, newResultNames, 1, resultNames.length);	return newResultNames;    }    /**     * Gets the data types of each of the columns produced for a single run.     * This method should really be static.     *     * @@return an array containing objects of the type of each column. The      * objects should be Strings, or Doubles.     */    public Object [] getResultTypes() {	Object [] resultTypes = m_SplitEvaluator.getResultTypes();	// Add in the types of our extra Result fields	Object [] newResultTypes = new Object [resultTypes.length + 1];	newResultTypes[0] = new Double(0);	System.arraycopy(resultTypes, 0, newResultTypes, 1, resultTypes.length);	return newResultTypes;    }    /**     * Gets a description of the internal settings of the result     * producer, sufficient for distinguishing a ResultProducer     * instance from another with different settings (ignoring     * those settings set through this interface). For example,     * a cross-validation ResultProducer may have a setting for the     * number of folds. For a given state, the results produced should     * be compatible. Typically if a ResultProducer is an OptionHandler,     * this string will represent the command line arguments required     * to set the ResultProducer to that state.     *     * @@return the description of the ResultProducer state, or null     * if no state is defined     */    public String getCompatibilityState() {	//Modify for Noise	String result = "-X " + m_NumFolds;	if (m_SplitEvaluator == null) {	    result += "<null SplitEvaluator>";	} else {	    result += "-W " + m_SplitEvaluator.getClass().getName();	}	return result + " --";    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String outputFileTipText() {	return "Set the destination for saving raw output. If the rawOutput "	    +"option is selected, then output from the splitEvaluator for "	    +"individual folds is saved. If the destination is a directory, "	    +"then each output is saved to an individual gzip file; if the "	    +"destination is a file, then each output is saved as an entry "	    +"in a zip file.";    }    /**     * Get the value of OutputFile.     *     * @@return Value of OutputFile.     */    public File getOutputFile() {    	return m_OutputFile;    }      /**     * Set the value of OutputFile.     *     * @@param newOutputFile Value to assign to OutputFile.     */    public void setOutputFile(File newOutputFile) {    	m_OutputFile = newOutputFile;    }      /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String numFoldsTipText() {	return "Number of folds to use in cross validation.";    }    /**     * Get the value of NumFolds.     *     * @@return Value of NumFolds.     */    public int getNumFolds() {    	return m_NumFolds;    }      /**     * Set the value of NumFolds.     *     * @@param newNumFolds Value to assign to NumFolds.     */    public void setNumFolds(int newNumFolds) {    	m_NumFolds = newNumFolds;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String plotPointsTipText() {	return "A list of specific points (Whole Numbers) to plot as a string of numbers separated by commas or spaces. "+	    "Whole numbers indicate a specific Percentages of Noise ";    }    /**     * Get the value of PlotPoints.     *     * @@return Value of PlotPoints.     */    public String getPlotPoints() {	StringBuffer buf = new StringBuffer();	if (m_PlotPoints != null) 	    for (int i=0; i < m_PlotPoints.length; i++) {		buf.append(m_PlotPoints[i]);		if (i != (m_PlotPoints.length -1)) 		    buf.append(" ");	    }	return buf.toString();    }      /**     * Set the value of PlotPoints.     *     * @@param plotPoints Value to assign to     * PlotPoints.     */    public void setPlotPoints(String plotPoints) {	m_PlotPoints = parsePlotPoints(plotPoints);    }    /**      * Parse a string of doubles separated by commas or spaces into a sorted array of doubles     */    protected double[] parsePlotPoints(String plotPoints) {	StringTokenizer tokenizer = new StringTokenizer(plotPoints," ,\t");	double[] result = null;	int count = tokenizer.countTokens();	if (count > 0)	    result = new double[count];	else	    return null;	int i = 0;	while(tokenizer.hasMoreTokens()) {	    result[i] = Double.parseDouble(tokenizer.nextToken());	    i++;	}	Arrays.sort(result);	return result;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String rawOutputTipText() {	return "Save raw output (useful for debugging). If set, then output is "	    +"sent to the destination specified by outputFile";    }    /**     * Get if raw split evaluator output is to be saved     * @@return true if raw split evalutor output is to be saved     */    public boolean getRawOutput() {	return m_debugOutput;    }      /**     * Set to true if raw split evaluator output is to be saved     * @@param d true if output is to be saved     */    public void setRawOutput(boolean d) {	m_debugOutput = d;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String classNoiseTipText() {	return "Add Noise to Class";    }    /**     * Get if Noise is to be added to Class     * @@return true if Noise is to be added to Class     */    public boolean getclassNoise() {	return m_classNoise;    }    /**     * Set to true if Noise is to be added to Class     * @@param d true if Noise is to be added to Class     */    public void setclassNoise(boolean d) {	m_classNoise = d;       	if (d == false)	    {		setclassNoiseTest(false);	    }    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String featureNoiseTipText() {	return "Add Noise to feature";    }    /**     * Get if Noise to be added in Features     * @@return true if  Noise to be added in Features     */    public boolean getfeatureNoise() {	return m_featureNoise;    }    /**     * Set to true if Noise is to be added to Features     * @@param d true if Noise is to be added to Features     */    public void setfeatureNoise(boolean d) {	m_featureNoise = d;	if (d == false)	    {	    setfeatureNoiseTest(false);	    }    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String featureMissTipText() {	return "Add Missing feature";    }    /**     * Get if Features are to be set Missing     * @@return true if  Features are to be set Missing     */    public boolean getfeatureMiss() {	return m_featureMiss;    }    /**     * Set to true if Features are to be set Missing     * @@param d true if Features are to be set Missing     */    public void setfeatureMiss(boolean d) {	m_featureMiss = d;	if (d == false)	    {		setfeatureMissTest(false);	    }    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String classNoiseTestTipText() {	return "Add Noise to Class while Testing";    }    /**     * Get if Noise is to be added to Class in Testing Set     * @@return true if Noise is to be added to Class in Testing Set     */    public boolean getclassNoiseTest() {	return m_classNoiseTest;    }    /**     * Set to true if Noise is to be added to Class in Testing     * @@param d true if Noise is to be added to Class in Testing     */    public void setclassNoiseTest(boolean d) {	m_classNoiseTest = d;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String featureNoiseTestTipText() {	return "Add Noise to feature while Testing";    }    /**     * Get if Noise is to be added to Feature in Testing Set     * @@return true if Noise is to be added to Feature in Testing Set     */    public boolean getfeatureNoiseTest() {	return m_featureNoiseTest;    }    /**     * Set to true if Noise is to be added in Fetures in Testing     * @@param d true if Noise is to be added in Fetures in Testing     */    public void setfeatureNoiseTest(boolean d) {	m_featureNoiseTest = d;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String featureMissTestTipText() {	return "Add Missing feature to Testing";    }    /**     * Get if Features are to be set Missing in Testing Set     * @@return true if Features are to be set Missing in Testing Set     */    public boolean getfeatureMissTest() {	return m_featureMissTest;    }    /**     * Set to true if Features are to be set Missing in Testing     * @@param d true if Features are to be set Missing in Testing     */    public void setfeatureMissTest(boolean d) {	m_featureMissTest = d;    }    /**     * Returns the tip text for this property     * @@return tip text for this property suitable for     * displaying in the explorer/experimenter gui     */    public String splitEvaluatorTipText() {	return "The evaluator to apply to the cross validation folds. "	    +"This may be a classifier, regression scheme etc.";    }     /**     * Get the SplitEvaluator.     *     * @@return the SplitEvaluator.     */    public SplitEvaluator getSplitEvaluator() {

⌨️ 快捷键说明

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