Examples of Instances


Examples of weka.core.Instances

   * @param newins a set of Instances
   */
  public void setInstances(Instances newins) {
    m_attribIndex = 0;
    m_as = null;
    m_data = new Instances(newins);
    if(m_colorAttrib!=null) {
      m_colorAttrib.removeAllItems();
      m_colorAttrib.addItem("No class");
      for(int i=0; i<m_data.numAttributes(); i++) {
  String type = "(" + Attribute.typeToStringShort(m_data.attribute(i)) + ")";
View Full Code Here

Examples of weka.core.Instances

  public static void main(String [] args) {
    if(args.length!=3) {
      final JFrame jf = new JFrame("AttribVisualization");
      AttributeVisualizationPanel ap = new AttributeVisualizationPanel();
      try {
        Instances ins = new Instances( new FileReader(args[0]) );
        ap.setInstances(ins);
        System.out.println("Loaded: "+args[0]+
                           "\nRelation: "+ap.m_data.relationName()+
                           "\nAttributes: "+ap.m_data.numAttributes());
        ap.setAttribute( Integer.parseInt(args[1]) );
View Full Code Here

Examples of weka.core.Instances

      if (ExplorerDefaults.getInitGenericObjectEditorFilter())
        getExplorer().notifyCapabilitiesFilterListener(
      Capabilities.forInstances(m_Instances));
      else
        getExplorer().notifyCapabilitiesFilterListener(
      Capabilities.forInstances(new Instances(m_Instances, 0)));

      m_Instances.setClassIndex(oldIndex);
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of weka.core.Instances

        if ((classIndex < 0) && (filter instanceof SupervisedFilter)) {
    throw new IllegalArgumentException("Class (colour) needs to " +
               "be set for supervised " +
               "filter.");
        }
        Instances copy = new Instances(m_Instances);
        copy.setClassIndex(classIndex);
        filter.setInputFormat(copy);
        Instances newInstances = Filter.useFilter(copy, filter);
        if (newInstances == null || newInstances.numAttributes() < 1) {
    throw new Exception("Dataset is empty.");
        }
        m_Log.statusMessage("Saving undo information");
        addUndoPoint();
        m_AttVisualizePanel.setColoringIndex(copy.classIndex());
        // if class was not set before, reset it again after use of filter
        if (m_Instances.classIndex() < 0)
    newInstances.setClassIndex(-1);
        m_Instances = newInstances;
        setInstances(m_Instances);
        if (m_Log instanceof TaskLogger) {
    ((TaskLogger)m_Log).taskFinished();
        }
View Full Code Here

Examples of weka.core.Instances

    if (m_IOThread == null) {
      m_FileChooser.setCapabilitiesFilter(m_FilterEditor.getCapabilitiesFilter());
      m_FileChooser.setAcceptAllFileFilterUsed(false);
      int returnVal = m_FileChooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
  Instances inst = new Instances(m_Instances);
  inst.setClassIndex(m_AttVisualizePanel.getColoringIndex());
  saveInstancesToFile(m_FileChooser.getSaver(), inst);
      }
      FileFilter temp = m_FileChooser.getFileFilter();
      m_FileChooser.setAcceptAllFileFilterUsed(true);
      m_FileChooser.setFileFilter(temp);
View Full Code Here

Examples of weka.core.Instances

    if (m_IOThread == null) {
      m_IOThread = new Thread() {
    public void run() {
      try {
        cnv.setSource(f);
        Instances inst = cnv.getDataSet();
        setInstances(inst);
      } catch (Exception ex) {
        m_Log.statusMessage(cnv.getClass().getName()+" failed to load "
         +f.getName());
        JOptionPane.showMessageDialog(PreprocessPanel.this,
View Full Code Here

Examples of weka.core.Instances

    if (m_IOThread == null) {
      m_IOThread = new Thread() {
  public void run() {
    try {
      m_Log.statusMessage("Reading from file...");
      Instances inst = loader.getDataSet();
      setInstances(inst);
    }
    catch (Exception ex) {
      m_Log.statusMessage(
    "File '" + loader.retrieveFile() + "' not recognised as an '"
View Full Code Here

Examples of weka.core.Instances

      m_IOThread = new Thread() {
  public void run() {
   
    try {
      m_Log.statusMessage("Reading from database...");
      final Instances i = iq.retrieveInstances();
      SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
    setInstances(new Instances(i));
        }
      });
      iq.disconnectFromDatabase();
    } catch (Exception ex) {
      m_Log.statusMessage("Problem executing DB query "+m_SQLQ);
View Full Code Here

Examples of weka.core.Instances

   * edits the current instances object in the viewer
   */
  public void edit() {
    ViewerDialog        dialog;
    int                 result;
    Instances           copy;
    Instances           newInstances;
   
    final int classIndex = m_AttVisualizePanel.getColoringIndex();
    copy   = new Instances(m_Instances);
    copy.setClassIndex(classIndex);
    dialog = new ViewerDialog(null);
    result = dialog.showDialog(copy);
    if (result == ViewerDialog.APPROVE_OPTION) {
      try {
        addUndoPoint();
      }
      catch (Exception e) {
        e.printStackTrace();
      }
      // if class was not set before, reset it again after use of filter
      newInstances = dialog.getInstances();
      if (m_Instances.classIndex() < 0)
        newInstances.setClassIndex(-1);
      setInstances(newInstances);
    }
  }
View Full Code Here

Examples of weka.core.Instances

   * updates the capabilities filter of the GOE
   *
   * @param filter  the new filter to use
   */
  protected void updateCapabilitiesFilter(Capabilities filter) {
    Instances     tempInst;
    Capabilities   filterClass;

    if (filter == null) {
      m_FilterEditor.setCapabilitiesFilter(new Capabilities(null));
      return;
    }
   
    if (!ExplorerDefaults.getInitGenericObjectEditorFilter())
      tempInst = new Instances(m_Instances, 0);
    else
      tempInst = new Instances(m_Instances);
    tempInst.setClassIndex(m_AttVisualizePanel.getColorBox().getSelectedIndex() - 1);

    try {
      filterClass = Capabilities.forInstances(tempInst);
    }
    catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.