本文整理汇总了Java中weka.core.converters.ConverterUtils类的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtils类的具体用法?Java ConverterUtils怎么用?Java ConverterUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConverterUtils类属于weka.core.converters包,在下文中一共展示了ConverterUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: train
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
private void train(String name) {
try {
Classifier randomForest = new RandomForest();
ConverterUtils.DataSource source = new ConverterUtils.DataSource(FOLDER + name);
dataSet = source.getDataSet();
dataSet.setClassIndex(dataSet.numAttributes() - 1);
randomForest.buildClassifier(dataSet);
classifier = randomForest;
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: train
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
public void train() {
try {
Classifier randomForest = new RandomForest();
ConverterUtils.DataSource source = new ConverterUtils.DataSource(FOLDER + "question-classifier.arff");
dataSet = source.getDataSet();
dataSet.setClassIndex(dataSet.numAttributes() - 1);
randomForest.buildClassifier(dataSet);
classifier = randomForest;
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: filterNonCoreLoaderFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core loaders if only those should be displayed.
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreLoaderFileFilters(
Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractLoader loader;
if (!getCoreConvertersOnly()) {
result = list;
} else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
loader = ConverterUtils
.getLoaderForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileLoader(loader.getClass().getName())) {
result.add(filter);
}
}
}
return result;
}
示例4: filterNonCoreSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core savers if only those should be displayed.
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreSaverFileFilters(
Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (!getCoreConvertersOnly()) {
result = list;
} else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileSaver(saver.getClass().getName())) {
result.add(filter);
}
}
}
return result;
}
示例5: filterSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters the list of file filters according to the currently set.
* Capabilities
*
* @param list the filters to check
* @return the filtered list of filters
*/
protected Vector<ExtensionFileFilter> filterSaverFileFilters(
Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (m_CapabilitiesFilter == null) {
result = list;
} else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (saver.getCapabilities().supports(m_CapabilitiesFilter)) {
result.add(filter);
}
}
}
return result;
}
示例6: loadFile
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* loads the specified ARFF file
*
* @param filename the file to load
* @param loaders optional varargs for a loader to use
*/
protected void loadFile(String filename, AbstractFileLoader... loaders) {
AbstractFileLoader loader;
if (loaders == null || loaders.length == 0) {
loader = ConverterUtils.getLoaderForFile(filename);
} else {
loader = loaders[0];
}
if (loader != null) {
try {
loader.setFile(new File(filename));
setInstances(loader.getDataSet());
} catch (Exception e) {
ComponentHelper
.showMessageBox(null, "Error loading file...", e.toString(),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
System.out.println(e);
setInstances(null);
}
}
}
示例7: filterNonCoreLoaderFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core loaders if only those should be displayed.
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreLoaderFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractLoader loader;
if (!getCoreConvertersOnly()) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
loader = ConverterUtils.getLoaderForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileLoader(loader.getClass().getName()))
result.add(filter);
}
}
return result;
}
示例8: filterNonCoreSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core savers if only those should be displayed.
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreSaverFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (!getCoreConvertersOnly()) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileSaver(saver.getClass().getName()))
result.add(filter);
}
}
return result;
}
示例9: filterSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters the list of file filters according to the currently set.
* Capabilities
*
* @param list the filters to check
* @return the filtered list of filters
*/
protected Vector<ExtensionFileFilter> filterSaverFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (m_CapabilitiesFilter == null) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (saver.getCapabilities().supports(m_CapabilitiesFilter))
result.add(filter);
}
}
return result;
}
示例10: nextIteration
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* Carries out the next iteration of the experiment.
*
* @throws Exception if an error occurs
*/
@Override
public void nextIteration() throws Exception {
if (m_UsePropertyIterator) {
if (m_CurrentProperty != m_PropertyNumber) {
setProperty(0, m_ResultProducer);
m_CurrentProperty = m_PropertyNumber;
}
}
if (m_CurrentInstances == null) {
File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
loader.setFile(currentFile);
Instances data = new Instances(loader.getDataSet());
MLUtils.prepareData(data);
m_CurrentInstances = data;
m_ResultProducer.setInstances(m_CurrentInstances);
}
m_ResultProducer.doRun(m_RunNumber);
advanceCounters();
}
示例11: save
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* Saves the data to the specified file.
*
* @param file the file to save the data to
* @param saver the saver to use, determines it automatically if null
*/
public void save(File file, AbstractFileSaver saver) {
if (saver == null)
saver = ConverterUtils.getSaverForFile(file);
try {
saver.setInstances(m_Data);
if ((saver.retrieveFile() == null) || !saver.retrieveFile().equals(file))
saver.setFile(file);
saver.writeBatch();
m_CurrentFile = file;
}
catch (Exception e) {
System.err.println("Failed to save data to '" + file + "':");
e.printStackTrace();
JOptionPane.showMessageDialog(
this,
"Failed to save dataset to '" + file + "':\n" + e,
"Error saving",
JOptionPane.ERROR_MESSAGE);
}
updateMenu();
}
示例12: filterNonCoreLoaderFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core loaders if only those should be displayed
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreLoaderFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractLoader loader;
if (!getCoreConvertersOnly()) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
loader = ConverterUtils.getLoaderForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileLoader(loader.getClass().getName()))
result.add(filter);
}
}
return result;
}
示例13: filterNonCoreSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters out all non-core savers if only those should be displayed
*
* @param list the list of filters to check
* @return the filtered list of filters
* @see #m_CoreConvertersOnly
*/
protected Vector<ExtensionFileFilter> filterNonCoreSaverFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (!getCoreConvertersOnly()) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (ConverterUtils.isCoreFileSaver(saver.getClass().getName()))
result.add(filter);
}
}
return result;
}
示例14: filterSaverFileFilters
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* filters the list of file filters according to the currently set
* Capabilities
*
* @param list the filters to check
* @return the filtered list of filters
*/
protected Vector<ExtensionFileFilter> filterSaverFileFilters(Vector<ExtensionFileFilter> list) {
Vector<ExtensionFileFilter> result;
int i;
ExtensionFileFilter filter;
AbstractSaver saver;
if (m_CapabilitiesFilter == null) {
result = list;
}
else {
result = new Vector<ExtensionFileFilter>();
for (i = 0; i < list.size(); i++) {
filter = list.get(i);
saver = ConverterUtils.getSaverForExtension(filter.getExtensions()[0]);
if (saver.getCapabilities().supports(m_CapabilitiesFilter))
result.add(filter);
}
}
return result;
}
示例15: loadFile
import weka.core.converters.ConverterUtils; //导入依赖的package包/类
/**
* loads the specified ARFF file
*
* @param filename the file to load
*/
private void loadFile(String filename) {
AbstractFileLoader loader;
loader = ConverterUtils.getLoaderForFile(filename);
if (loader != null) {
try {
loader.setFile(new File(filename));
m_Data = loader.getDataSet();
}
catch (Exception e) {
ComponentHelper.showMessageBox(
null,
Messages.getInstance().getString("ArffTableModel_LoadFile_ComponentHelperShowMessageBox_Text"),
e.toString(),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE );
System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +e);
m_Data = null;
}
}
}