本文整理匯總了Java中weka.core.Utils.removeSubstring方法的典型用法代碼示例。如果您正苦於以下問題:Java Utils.removeSubstring方法的具體用法?Java Utils.removeSubstring怎麽用?Java Utils.removeSubstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.core.Utils
的用法示例。
在下文中一共展示了Utils.removeSubstring方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: templateString
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Returns a string descriptive of the resultset key column values for this
* resultset
*
* @return a value of type 'String'
*/
protected String templateString() {
String result = "";
String tempResult = "";
for (int m_ResultsetKeyColumn : m_ResultsetKeyColumns) {
tempResult = m_Template.toString(m_ResultsetKeyColumn) + ' ';
// compact the string
tempResult = Utils.removeSubstring(tempResult, "weka.classifiers.");
tempResult = Utils.removeSubstring(tempResult, "weka.filters.");
tempResult = Utils.removeSubstring(tempResult,
"weka.attributeSelection.");
result += tempResult;
}
return result.trim();
}
示例2: computeBounds
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Sets up the bounds on our x and y axes to fit the dataset. Also repaints
* the x and y axes.
*/
private void computeBounds() {
m_boundaryPanel.computeMinMaxAtts(); // delegate to the BoundaryPanel
String xName = (String) m_xAttBox.getSelectedItem();
if (xName == null) {
return;
}
xName = Utils.removeSubstring(xName, "X: ");
xName = Utils.removeSubstring(xName, " (Num)");
String yName = (String) m_yAttBox.getSelectedItem();
yName = Utils.removeSubstring(yName, "Y: ");
yName = Utils.removeSubstring(yName, " (Num)");
m_xIndex = -1;
m_yIndex = -1;
for (int i = 0; i < m_trainingInstances.numAttributes(); i++) {
if (m_trainingInstances.attribute(i).name().equals(xName)) {
m_xIndex = i;
}
if (m_trainingInstances.attribute(i).name().equals(yName)) {
m_yIndex = i;
}
}
m_minX = m_boundaryPanel.getMinXBound();
m_minY = m_boundaryPanel.getMinYBound();
m_maxX = m_boundaryPanel.getMaxXBound();
m_maxY = m_boundaryPanel.getMaxYBound();
// System.err.println("setting bounds to " + m_minX + " " + m_minY + " " +
// m_maxX + " " + m_maxY);
m_xAxisPanel.repaint(0, 0, 0, m_xAxisPanel.getWidth(),
m_xAxisPanel.getHeight());
m_yAxisPanel.repaint(0, 0, 0, m_yAxisPanel.getWidth(),
m_yAxisPanel.getHeight());
}
示例3: sanitizeFilename
import weka.core.Utils; //導入方法依賴的package包/類
/**
* makes sure that the filename is valid, i.e., replaces slashes, backslashes
* and colons with underscores ("_"). Also try to prevent filename from
* becoming insanely long by removing package part of class names.
*
* @param filename the filename to cleanse
* @return the cleansed filename
*/
protected String sanitizeFilename(String filename) {
filename = filename.replaceAll("\\\\", "_").replaceAll(":", "_")
.replaceAll("/", "_");
filename = Utils.removeSubstring(filename,
"weka.filters.supervised.instance.");
filename = Utils.removeSubstring(filename,
"weka.filters.supervised.attribute.");
filename = Utils.removeSubstring(filename,
"weka.filters.unsupervised.instance.");
filename = Utils.removeSubstring(filename,
"weka.filters.unsupervised.attribute.");
filename = Utils.removeSubstring(filename, "weka.clusterers.");
filename = Utils.removeSubstring(filename, "weka.associations.");
filename = Utils.removeSubstring(filename, "weka.attributeSelection.");
filename = Utils.removeSubstring(filename, "weka.estimators.");
filename = Utils.removeSubstring(filename, "weka.datagenerators.");
if (!m_isDBSaver && !m_relationNameForFilename) {
filename = "";
try {
if (m_Saver.filePrefix().equals("")) {
m_Saver.setFilePrefix("no-name");
}
} catch (Exception ex) {
System.err.println(ex);
}
}
return filename;
}
示例4: doRun
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Gets the results for a specified run number. Different run numbers
* correspond to different randomizations of the data. Results produced should
* be sent to the current ResultListener
*
* @param run the run number to get results for.
* @throws Exception if a problem occurs while getting the results
*/
@Override
public void doRun(int run) throws Exception {
if (getRawOutput()) {
if (m_ZipDest == null) {
m_ZipDest = new OutputZipper(m_OutputFile);
}
}
if (m_Instances == null) {
throw new Exception("No Instances set");
}
// Randomize on a copy of the original dataset
Instances runInstances = new Instances(m_Instances);
Random random = new Random(run);
runInstances.randomize(random);
if (runInstances.classAttribute().isNominal()) {
runInstances.stratify(m_NumFolds);
}
for (int fold = 0; fold < m_NumFolds; fold++) {
// Add in some fields to the key like run and fold number, dataset name
Object[] seKey = m_SplitEvaluator.getKey();
Object[] key = new Object[seKey.length + 3];
key[0] = Utils.backQuoteChars(m_Instances.relationName());
key[1] = "" + run;
key[2] = "" + (fold + 1);
System.arraycopy(seKey, 0, key, 3, seKey.length);
if (m_ResultListener.isResultRequired(this, key)) {
Instances train = runInstances.trainCV(m_NumFolds, fold, random);
Instances test = runInstances.testCV(m_NumFolds, fold);
try {
Object[] seResults = m_SplitEvaluator.getResult(train, test);
Object[] results = new Object[seResults.length + 1];
results[0] = getTimestamp();
System.arraycopy(seResults, 0, results, 1, seResults.length);
if (m_debugOutput) {
String resultName = ("" + run + "." + (fold + 1) + "."
+ Utils.backQuoteChars(runInstances.relationName()) + "." + m_SplitEvaluator
.toString()).replace(' ', '_');
resultName = Utils.removeSubstring(resultName, "weka.classifiers.");
resultName = Utils.removeSubstring(resultName, "weka.filters.");
resultName = Utils.removeSubstring(resultName,
"weka.attributeSelection.");
m_ZipDest.zipit(m_SplitEvaluator.getRawResultOutput(), resultName);
}
m_ResultListener.acceptResult(this, key, results);
} catch (Exception ex) {
// Save the train and test datasets for debugging purposes?
throw ex;
}
}
}
}
示例5: doRun
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Gets the results for a specified run number. Different run numbers
* correspond to different randomizations of the data. Results produced should
* be sent to the current ResultListener
*
* @param run the run number to get results for.
* @throws Exception if a problem occurs while getting the results
*/
@Override
public void doRun(int run) throws Exception {
if (getRawOutput()) {
if (m_ZipDest == null) {
m_ZipDest = new OutputZipper(m_OutputFile);
}
}
if (m_Instances == null) {
throw new Exception("No Instances set");
}
// Compute run and fold number from given run
int fold = (run - 1) % m_NumFolds;
run = ((run - 1) / m_NumFolds) + 1;
// Randomize on a copy of the original dataset
Instances runInstances = new Instances(m_Instances);
Random random = new Random(run);
runInstances.randomize(random);
if (runInstances.classAttribute().isNominal()) {
runInstances.stratify(m_NumFolds);
}
// Add in some fields to the key like run and fold number, dataset name
Object[] seKey = m_SplitEvaluator.getKey();
Object[] key = new Object[seKey.length + 3];
key[0] = Utils.backQuoteChars(m_Instances.relationName());
key[1] = "" + run;
key[2] = "" + (fold + 1);
System.arraycopy(seKey, 0, key, 3, seKey.length);
if (m_ResultListener.isResultRequired(this, key)) {
// Just to make behaviour absolutely consistent with
// CrossValidationResultProducer
for (int tempFold = 0; tempFold < fold; tempFold++) {
runInstances.trainCV(m_NumFolds, tempFold, random);
}
Instances train = runInstances.trainCV(m_NumFolds, fold, random);
Instances test = runInstances.testCV(m_NumFolds, fold);
try {
Object[] seResults = m_SplitEvaluator.getResult(train, test);
Object[] results = new Object[seResults.length + 1];
results[0] = getTimestamp();
System.arraycopy(seResults, 0, results, 1, seResults.length);
if (m_debugOutput) {
String resultName = ("" + run + "." + (fold + 1) + "."
+ Utils.backQuoteChars(runInstances.relationName()) + "." + m_SplitEvaluator
.toString()).replace(' ', '_');
resultName = Utils.removeSubstring(resultName, "weka.classifiers.");
resultName = Utils.removeSubstring(resultName, "weka.filters.");
resultName = Utils.removeSubstring(resultName,
"weka.attributeSelection.");
m_ZipDest.zipit(m_SplitEvaluator.getRawResultOutput(), resultName);
}
m_ResultListener.acceptResult(this, key, results);
} catch (Exception ex) {
// Save the train and test datasets for debugging purposes?
throw ex;
}
}
}
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:73,代碼來源:CrossValidationSplitResultProducer.java