Esempio n. 1
0
  public void setDatasetKeyFromDialog() {

    ListSelectorDialog jd = new ListSelectorDialog(null, m_DatasetKeyList);

    // Open the dialog
    int result = jd.showDialog();

    // If accepted, update the ttester
    if (result == ListSelectorDialog.APPROVE_OPTION) {
      int[] selected = m_DatasetKeyList.getSelectedIndices();
      String selectedList = "";
      for (int i = 0; i < selected.length; i++) {
        selectedList += "," + (selected[i] + 1);
      }
      Range generatorRange = new Range();
      if (selectedList.length() != 0) {
        try {
          generatorRange.setRanges(selectedList);
        } catch (Exception ex) {
          ex.printStackTrace();
          System.err.println(ex.getMessage());
        }
      }
      m_TTester.setDatasetKeyColumns(generatorRange);
      setTTester();
    }
  }
Esempio n. 2
0
  /** deletes the chosen attributes */
  public void deleteAttributes() {
    ListSelectorDialog dialog;
    ArffSortedTableModel model;
    Object[] atts;
    int[] indices;
    int i;
    JList list;
    int result;

    list = new JList(getAttributes());
    dialog = new ListSelectorDialog(null, list);
    result = dialog.showDialog();

    if (result != ListSelectorDialog.APPROVE_OPTION) return;

    atts = list.getSelectedValues();

    // really?
    if (ComponentHelper.showMessageBox(
            getParent(),
            "Confirm...",
            "Do you really want to delete these " + atts.length + " attributes?",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE)
        != JOptionPane.YES_OPTION) return;

    model = (ArffSortedTableModel) m_TableArff.getModel();
    indices = new int[atts.length];
    for (i = 0; i < atts.length; i++) indices[i] = model.getAttributeColumn(atts[i].toString());

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    model.deleteAttributes(indices);
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  }
Esempio n. 3
0
  /** Queries the user enough to make a database query to retrieve experiment results. */
  protected void setInstancesFromDBaseQuery() {

    try {
      if (m_InstanceQuery == null) {
        m_InstanceQuery = new InstanceQuery();
      }
      String dbaseURL = m_InstanceQuery.getDatabaseURL();
      dbaseURL =
          (String)
              JOptionPane.showInputDialog(
                  this,
                  "Enter the database URL",
                  "Query Database",
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  dbaseURL);
      if (dbaseURL == null) {
        m_FromLab.setText("Cancelled");
        return;
      }
      m_InstanceQuery.setDatabaseURL(dbaseURL);
      m_InstanceQuery.connectToDatabase();
      if (!m_InstanceQuery.experimentIndexExists()) {
        m_FromLab.setText("No experiment index");
        return;
      }
      m_FromLab.setText("Getting experiment index");
      Instances index =
          m_InstanceQuery.retrieveInstances("SELECT * FROM " + InstanceQuery.EXP_INDEX_TABLE);
      if (index.numInstances() == 0) {
        m_FromLab.setText("No experiments available");
        return;
      }
      m_FromLab.setText("Got experiment index");

      DefaultListModel lm = new DefaultListModel();
      for (int i = 0; i < index.numInstances(); i++) {
        lm.addElement(index.instance(i).toString());
      }
      JList jl = new JList(lm);
      ListSelectorDialog jd = new ListSelectorDialog(null, jl);
      int result = jd.showDialog();
      if (result != ListSelectorDialog.APPROVE_OPTION) {
        m_FromLab.setText("Cancelled");
        return;
      }
      Instance selInst = index.instance(jl.getSelectedIndex());
      Attribute tableAttr = index.attribute(InstanceQuery.EXP_RESULT_COL);
      String table = InstanceQuery.EXP_RESULT_PREFIX + selInst.toString(tableAttr);

      setInstancesFromDatabaseTable(table);
    } catch (Exception ex) {
      m_FromLab.setText("Problem reading database");
    }
  }
Esempio n. 4
0
  /** Queries the user enough to make a database query to retrieve experiment results. */
  protected void setInstancesFromDBaseQuery() {

    try {
      if (m_InstanceQuery == null) {
        m_InstanceQuery = new InstanceQuery();
      }
      String dbaseURL = m_InstanceQuery.getDatabaseURL();
      String username = m_InstanceQuery.getUsername();
      String passwd = m_InstanceQuery.getPassword();
      /*dbaseURL = (String) JOptionPane.showInputDialog(this,
      "Enter the database URL",
      "Query Database",
      JOptionPane.PLAIN_MESSAGE,
      null,
      null,
      dbaseURL);*/

      DatabaseConnectionDialog dbd = new DatabaseConnectionDialog(null, dbaseURL, username);
      dbd.setVisible(true);

      // if (dbaseURL == null) {
      if (dbd.getReturnValue() == JOptionPane.CLOSED_OPTION) {
        m_FromLab.setText("Cancelled");
        return;
      }
      dbaseURL = dbd.getURL();
      username = dbd.getUsername();
      passwd = dbd.getPassword();
      m_InstanceQuery.setDatabaseURL(dbaseURL);
      m_InstanceQuery.setUsername(username);
      m_InstanceQuery.setPassword(passwd);
      m_InstanceQuery.setDebug(dbd.getDebug());

      m_InstanceQuery.connectToDatabase();
      if (!m_InstanceQuery.experimentIndexExists()) {
        System.err.println("not found");
        m_FromLab.setText("No experiment index");
        m_InstanceQuery.disconnectFromDatabase();
        return;
      }
      System.err.println("found");
      m_FromLab.setText("Getting experiment index");
      Instances index =
          m_InstanceQuery.retrieveInstances("SELECT * FROM " + InstanceQuery.EXP_INDEX_TABLE);
      if (index.numInstances() == 0) {
        m_FromLab.setText("No experiments available");
        m_InstanceQuery.disconnectFromDatabase();
        return;
      }
      m_FromLab.setText("Got experiment index");

      DefaultListModel lm = new DefaultListModel();
      for (int i = 0; i < index.numInstances(); i++) {
        lm.addElement(index.instance(i).toString());
      }
      JList jl = new JList(lm);
      jl.setSelectedIndex(0);
      int result;
      // display dialog only if there's not just one result!
      if (jl.getModel().getSize() != 1) {
        ListSelectorDialog jd = new ListSelectorDialog(null, jl);
        result = jd.showDialog();
      } else {
        result = ListSelectorDialog.APPROVE_OPTION;
      }
      if (result != ListSelectorDialog.APPROVE_OPTION) {
        m_FromLab.setText("Cancelled");
        m_InstanceQuery.disconnectFromDatabase();
        return;
      }
      Instance selInst = index.instance(jl.getSelectedIndex());
      Attribute tableAttr = index.attribute(InstanceQuery.EXP_RESULT_COL);
      String table = InstanceQuery.EXP_RESULT_PREFIX + selInst.toString(tableAttr);
      setInstancesFromDatabaseTable(table);

    } catch (Exception ex) {
      // 1. print complete stacktrace
      ex.printStackTrace();
      // 2. print message in panel
      m_FromLab.setText("Problem reading database: '" + ex.getMessage() + "'");
    }
  }
Esempio n. 5
0
  public void setDisplayedFromDialog() {
    ListSelectorDialog jd = new ListSelectorDialog(null, m_DisplayedList);

    // Open the dialog
    jd.showDialog();
  }
Esempio n. 6
0
  public void setTestBaseFromDialog() {
    ListSelectorDialog jd = new ListSelectorDialog(null, m_TestsList);

    // Open the dialog
    jd.showDialog();
  }
Esempio n. 7
0
  public void setDatasetKeyFromDialog() {

    ListSelectorDialog jd = new ListSelectorDialog(null, m_DatasetKeyList);

    // Open the dialog
    int result = jd.showDialog();
    // =============== BEGIN EDIT melville ===============
    // Check if learning curves should be generated
    boolean noise = false;
    boolean learning = false;
    boolean fraction = false;
    int learning_key = -1;

    // If accepted, update the ttester
    if (result == ListSelectorDialog.APPROVE_OPTION) {
      int[] selected = m_DatasetKeyList.getSelectedIndices();
      String selectedList = "";
      Object[] selected_string = m_DatasetKeyList.getSelectedValues();
      for (int i = 0; i < selected.length; i++) {
        if (((String) selected_string[i]).toLowerCase().equals("key_noise_levels")) {
          learning_key = i;
          learning = true;
          // fraction = true;
          noise = true;
        } else if (((String) selected_string[i]).toLowerCase().equals("key_fraction_instances")) {
          learning_key = i;
          learning = true;
          fraction = true;
        } else if (((String) selected_string[i]).toLowerCase().equals("key_total_instances")
            && !learning) {
          learning = true;
          learning_key = i;
        } else selectedList += "," + (selected[i] + 1);
      }

      m_TTester.setLearningCurve(learning);
      m_TTester.setFraction(fraction);
      if (learning) { // get points on the learning curve
        selectedList += "," + (selected[learning_key] + 1);
        Attribute attr;
        if (noise) { // override fraction
          attr = m_Instances.attribute("Key_Noise_levels");
        } else if (fraction) {
          attr = m_Instances.attribute("Key_Fraction_instances");
        } else {
          attr = m_Instances.attribute("Key_Total_instances");
        }
        double[] pts = new double[attr.numValues()];
        for (int k = 0; k < attr.numValues(); k++) {
          pts[k] = Double.parseDouble(attr.value(k));
        }
        Arrays.sort(pts);
        m_TTester.setPoints(pts);
      }
      // ================ END EDIT melville ================

      Range generatorRange = new Range();
      if (selectedList.length() != 0) {
        try {
          generatorRange.setRanges(selectedList);
        } catch (Exception ex) {
          ex.printStackTrace();
          System.err.println(ex.getMessage());
        }
      }
      m_TTester.setDatasetKeyColumns(generatorRange);
      setTTester();
    }
  }