Java 类weka.core.converters.ConverterUtils 实例源码

项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:repo.kmeanspp.silhouette_score    文件:ArffTableModel.java   
/**
 * 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);
    }
  }
}
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:umple    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:umple    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:umple    文件:ConverterFileChooser.java   
/**
 * 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;
}
项目:umple    文件:ArffTableModel.java   
/**
 * 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);
    }
  }
}
项目:meka    文件:MekaExperiment.java   
/**
 * 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();
}
项目:meka    文件:Explorer.java   
/**
 * 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();
}
项目:jbossBA    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:jbossBA    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:jbossBA    文件:ConverterFileChooser.java   
/**
  * 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;
 }
项目:jbossBA    文件:ArffTableModel.java   
/**
 * 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;
    }
  }
}
项目:master-thesis    文件:DBScanImbalancedAlgorithm.java   
@Override
public Instances loadDataFile(String filename) {

    String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
    path = path.concat(filename);
    System.out.println("Path:\t\t" + path);
    System.out.println("Dataset:\t" + filename);
    ConverterUtils.DataSource source;
    try {
        source = new ConverterUtils.DataSource(path);
        data = source.getDataSet();
        System.out.println(filename + " -> Data loaded.");
        // Normalizacja atrybutów, domyslne ustawienia
        Normalize filterNorm = new Normalize();
        filterNorm.setInputFormat(data);
        data = Filter.useFilter(data, filterNorm);
        System.out.println("Data Normalized");
        System.out.println();
        return data;
    } catch (Exception e) {
        e.printStackTrace();

    }
    return null;

}
项目:master-thesis    文件:DBScanImbalancedAlgorithm.java   
@Override
public Instances loadDataFile(String filename) {
    this.filename = filename;
    String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
    path = path.concat(filename);
    //System.out.println("Path:\t\t" + path);
    //.out.println("Dataset:\t" + filename);
    ConverterUtils.DataSource source;
    try {
        source = new ConverterUtils.DataSource(path);
        data = source.getDataSet();
        //System.out.println(filename + " -> Data loaded.");
        // Normalizacja atrybutów, domyslne ustawienia
        Normalize filterNorm = new Normalize();
        filterNorm.setInputFormat(data);
        data = Filter.useFilter(data, filterNorm);
        //System.out.println("Data Normalized");
        //System.out.println();
        return data;
    } catch (Exception e) {
        e.printStackTrace();

    }
    return null;

}
项目:master-thesis    文件:ClusterImbalancedAlgorithm.java   
@Override
public Instances loadDataFile(String filename) {
    this.filename = filename;
    String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
    path = path.concat(filename);
    System.out.println("Path:\t\t" + path);
    System.out.println("Dataset:\t" + filename);
    ConverterUtils.DataSource source;
    try {
        source = new ConverterUtils.DataSource(path);
        data = source.getDataSet();
        System.out.println(filename + " -> Data loaded.");
        // Normalizacja atrybutów, domyslne ustawienia
        Normalize filterNorm = new Normalize();
        filterNorm.setInputFormat(data);
        data = Filter.useFilter(data, filterNorm);
        System.out.println("Data Normalized");
        System.out.println();
        return data;
    } catch (Exception e) {
        e.printStackTrace();

    }
    return null;

}
项目:master-thesis    文件:ClusterImbalancedAlgorithmXMeans.java   
@Override
public Instances loadDataFile(String filename) {
    this.filename = filename;
    String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
    path = path.concat(filename);
    System.out.println("Path:\t\t" + path);
    System.out.println("Dataset:\t" + filename);
    ConverterUtils.DataSource source;
    try {
        source = new ConverterUtils.DataSource(path);
        data = source.getDataSet();
        System.out.println(filename + " -> Data loaded.");
        // Normalizacja atrybutów, domyslne ustawienia
        Normalize filterNorm = new Normalize();
        filterNorm.setInputFormat(data);
        data = Filter.useFilter(data, filterNorm);
        System.out.println("Data Normalized");
        System.out.println();
        return data;
    } catch (Exception e) {
        e.printStackTrace();

    }
    return null;

}
项目:master-thesis    文件:LoadUtils.java   
public static Instances loadDataFile(String filename) {
        Instances data;
        String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
        path = path.concat(filename);
//        System.out.println("Path:\t\t" + path);
//        System.out.println("Dataset:\t" + filename);
        ConverterUtils.DataSource source;
        try {
            source = new ConverterUtils.DataSource(path);
            data = source.getDataSet();
            //System.out.println(filename + " -> Data loaded.");
            // Normalizacja atrybutów, domyslne ustawienia
            Normalize filterNorm = new Normalize();
            filterNorm.setInputFormat(data);
            data = Filter.useFilter(data, filterNorm);
            //System.out.println("Data Normalized");
            //System.out.println();
            return data;
        } catch (Exception e) {
            e.printStackTrace();

        }
        return null;

    }
项目:master-thesis    文件:LoadUtils.java   
public static Instances loadDataFilePrint(String filename) {
    Instances data;
    String path = System.getProperty("user.dir") + "\\resources\\datasets\\";
    path = path.concat(filename);
    System.out.println("Path:\t\t" + path);
    System.out.println("Dataset:\t" + filename);
    ConverterUtils.DataSource source;
    try {
        source = new ConverterUtils.DataSource(path);
        data = source.getDataSet();
        System.out.println(filename + " -> Data loaded.");
        // Normalizacja atrybutów, domyslne ustawienia
        Normalize filterNorm = new Normalize();
        filterNorm.setInputFormat(data);
        data = Filter.useFilter(data, filterNorm);
        System.out.println("Data Normalized");
        System.out.println();
        return data;
    } catch (Exception e) {
        e.printStackTrace();

    }
    return null;

}
项目:parlo    文件:SentenceClassifier.java   
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();
    }
}
项目:parlo    文件:QuestionClassifier.java   
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();
    }
}
项目:GeneralisedRulesAlgorithm    文件:GRules.java   
public static void main(String[] args){
    GRules GRulesLearner = new GRules();

    try {
    ConverterUtils.DataSource source = new ConverterUtils.DataSource("data/car.arff");
    Instances originalDataset = source.getDataSet();

    // split data 80/20
    int trainSize = (int) Math.round(originalDataset.numInstances() * 0.8
        / 100);
    int testSize = originalDataset.numInstances() - trainSize;
    Instances train = new Instances(originalDataset, 0, trainSize);
    Instances test = new Instances(originalDataset, trainSize, testSize);

    train.randomize(new java.util.Random(0));

    // train the rules learner
    List<List<Term>> rightSideRules = GRulesLearner.learnRightSide(train);
    List<Rule> completedRules = GRulesLearner.induceCompleteRules(rightSideRules, originalDataset);

    // try to predict an instance
    System.out.println("A testing instance: ");
    System.out.println(test.get(10));
    System.out.println("A rule covered the instance: ");
    System.out.println(GRulesLearner.predict(test.get(10), completedRules).nicePrint());

    } catch (Exception ex) {
        System.err.println(ex.toString());
    }
}
项目:hungrydragon    文件:ModelGenerator.java   
public Instances loadDataset(String path) {
    Instances dataset = null;
    try {
        dataset = ConverterUtils.DataSource.read(path);
        if (dataset.classIndex() == -1) {
            dataset.setClassIndex(dataset.numAttributes() - 1);
        }
    } catch (Exception ex) {
        Logger.getLogger(ModelGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }

    return dataset;
}
项目:wekaDeeplearning4j    文件:Dl4jStringToWord2VecTest.java   
public void testReuters() throws Exception {
  final String arffPath = "datasets/text/ReutersCorn-train.arff";
  ConverterUtils.DataSource ds = new ConverterUtils.DataSource(arffPath);
  final Instances data = ds.getDataSet();
  Dl4jStringToWord2Vec dl4jw2v = new Dl4jStringToWord2Vec();
  dl4jw2v.setInputFormat(data);
  Instances d = Filter.useFilter(data, dl4jw2v);
}
项目:repo.kmeanspp.silhouette_score    文件:Experiment.java   
/**
 * Carries out the next iteration of the experiment.
 * 
 * @throws Exception if an error occurs
 */
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());
    // only set class attribute if not already done by loader
    if (data.classIndex() == -1) {
      if (m_ClassFirst) {
        data.setClassIndex(0);
      } else {
        data.setClassIndex(data.numAttributes() - 1);
      }
    }
    m_CurrentInstances = data;
    m_ResultProducer.setInstances(m_CurrentInstances);
  }

  m_ResultProducer.doRun(m_RunNumber);

  advanceCounters();
}
项目:repo.kmeanspp.silhouette_score    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
@Override
public void run() {

  try {
    m_Log.statusMessage("Reading from URL...");
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage("Problem reading " + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
                  "Couldn't read from URL:\n"
                  + u + "\n"
                  + ex.getMessage(),
                  "Load Instances",
                  JOptionPane.ERROR_MESSAGE);
  }

  m_IOThread = null;
}
     };
     m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority
     m_IOThread.start();
   } else {
     JOptionPane.showMessageDialog(this,
                "Can't load at this time,\n"
                + "currently busy with other IO",
                "Load Instances",
                JOptionPane.WARNING_MESSAGE);
   }
 }
项目:repo.kmeanspp.silhouette_score    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
    "Cannot perform undo operation!\n" + e.toString(),
    "Undo",
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * sets the current converter according to the current filefilter.
 */
protected void updateCurrentConverter() {
  String[] extensions;
  Object newConverter;

  if (getFileFilter() == null) {
    return;
  }

  if (!isAcceptAllFileFilterUsed()) {
    // determine current converter
    extensions = ((ExtensionFileFilter) getFileFilter()).getExtensions();
    if (m_DialogType == LOADER_DIALOG) {
      newConverter = ConverterUtils.getLoaderForExtension(extensions[0]);
    } else {
      newConverter = ConverterUtils.getSaverForExtension(extensions[0]);
    }

    try {
      if (m_CurrentConverter == null) {
        m_CurrentConverter = newConverter;
      } else {
        if (!m_CurrentConverter.getClass().equals(newConverter.getClass())) {
          m_CurrentConverter = newConverter;
        }
      }
    } catch (Exception e) {
      m_CurrentConverter = null;
      e.printStackTrace();
    }
  } else {
    m_CurrentConverter = null;
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * configures the current converter.
 * 
 * @param dialogType the type of dialog to configure for
 */
protected void configureCurrentConverter(int dialogType) {
  String filename;
  File currFile;

  if ((getSelectedFile() == null) || (getSelectedFile().isDirectory())) {
    return;
  }

  filename = getSelectedFile().getAbsolutePath();

  if (m_CurrentConverter == null) {
    if (dialogType == LOADER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getLoaderForFile(filename);
    } else if (dialogType == SAVER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getSaverForFile(filename);
    } else {
      throw new IllegalStateException("Cannot determine loader/saver!");
    }

    // none found?
    if (m_CurrentConverter == null) {
      return;
    }
  }

  try {
    currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile();
    if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename))) {
      ((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename));
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ArffViewerMainPanel.java   
/**
 * saves the current data into a file
 */
public void saveFile() {
  ArffPanel panel;
  String filename;
  AbstractSaver saver;

  // no panel? -> exit
  panel = getCurrentPanel();
  if (panel == null) {
    return;
  }

  filename = panel.getFilename();

  if (filename.equals(ArffPanel.TAB_INSTANCES)) {
    saveFileAs();
  } else {
    saver = ConverterUtils.getSaverForFile(filename);
    try {
      saver.setFile(new File(filename));
      saver.setInstances(panel.getInstances());
      saver.writeBatch();
      panel.setChanged(false);
      setCurrentFilename(filename);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:SetInstancesPanel.java   
/**
 * Loads instances from a URL.
 * 
 * @param u the URL to load from.
 */
protected void setInstancesFromURL(URL u) {
  boolean incremental = m_readIncrementally;

  try {
    m_Loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (m_Loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);

    // not an incremental loader?
    if (!(m_Loader instanceof IncrementalConverter))
      incremental = false;

    // load
    ((URLSourcedLoader) m_Loader).setURL(u.toString());
    if (incremental) {
      m_Summary.setShowZeroInstancesAsUnknown(m_showZeroInstancesAsUnknown);
      setInstances(m_Loader.getStructure());
    } else {
      m_Summary.setShowZeroInstancesAsUnknown(false);
      setInstances(m_Loader.getDataSet());
    }
  } catch (Exception ex) {
    JOptionPane.showMessageDialog(this, "Couldn't read from URL:\n" + u,
        "Load Instances", JOptionPane.ERROR_MESSAGE);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:WekaPackageManager.java   
/**
 * Refresh the generic object editor properties via re-running of the dynamic
 * class discovery process.
 */
public static void refreshGOEProperties() {
  ClassDiscovery.clearClassCache();
  GenericPropertiesCreator.regenerateGlobalOutputProperties();
  GenericObjectEditor.determineClasses();
  ConverterUtils.initialize();
  KnowledgeFlowApp.disposeSingleton();
  KnowledgeFlowApp.reInitialize();
}
项目:autoweka    文件:Experiment.java   
/**
  * Carries out the next iteration of the experiment.
  *
  * @throws Exception if an error occurs
  */
 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());
     // only set class attribute if not already done by loader
     if (data.classIndex() == -1) {
if (m_ClassFirst) {
  data.setClassIndex(0);
} else {
  data.setClassIndex(data.numAttributes() - 1);
}
     }
     m_CurrentInstances = data;
     m_ResultProducer.setInstances(m_CurrentInstances);
   }

   m_ResultProducer.doRun(m_RunNumber);

   advanceCounters();
 }
项目:autoweka    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
public void run() {

  try {
    m_Log.statusMessage("Reading from URL...");
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage("Problem reading " + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
                  "Couldn't read from URL:\n"
                  + u + "\n"
                  + ex.getMessage(),
                  "Load Instances",
                  JOptionPane.ERROR_MESSAGE);
  }

  m_IOThread = null;
}
     };
     m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority
     m_IOThread.start();
   } else {
     JOptionPane.showMessageDialog(this,
                "Can't load at this time,\n"
                + "currently busy with other IO",
                "Load Instances",
                JOptionPane.WARNING_MESSAGE);
   }
 }
项目:autoweka    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
    "Cannot perform undo operation!\n" + e.toString(),
    "Undo",
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * sets the current converter according to the current filefilter.
  */
 protected void updateCurrentConverter() {
   String[] extensions;
   Object   newConverter;

   if (getFileFilter() == null)
     return;

   if (!isAcceptAllFileFilterUsed()) {
     // determine current converter
     extensions = ((ExtensionFileFilter) getFileFilter()).getExtensions();
     if (m_DialogType == LOADER_DIALOG)
newConverter = ConverterUtils.getLoaderForExtension(extensions[0]);
     else
newConverter = ConverterUtils.getSaverForExtension(extensions[0]);

     try {
if (m_CurrentConverter == null) {
  m_CurrentConverter = newConverter;
}
else {
  if (!m_CurrentConverter.getClass().equals(newConverter.getClass()))
    m_CurrentConverter = newConverter;
}
     }
     catch (Exception e) {
m_CurrentConverter = null;
e.printStackTrace();
     }
   }
   else {
     m_CurrentConverter = null;
   }
 }