/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addElement(new Option( "\tFull path to serialized classifier to include.\n" + "\tMay be specified multiple times to include\n" + "\tmultiple serialized classifiers. Note: it does\n" + "\tnot make sense to use pre-built classifiers in\n" + "\ta cross-validation.", "P", 1, "-P <path to serialized " + "classifier>")); result.addElement(new Option("\tThe combination rule to use\n" + "\t(default: AVG)", "R", 1, "-R " + Tag.toOptionList(TAGS_RULES))); result.addElement(new Option( "\tSuppress the printing of the individual models in the output", "do-not-print", 0, "-do-not-print")); result.addAll(Collections.list(super.listOptions())); return result.elements(); }
private void setUpFileFormatComboBox() { m_fileFormatBox = new JComboBox(); for (int i = 0; i < SerializedModelSaver.s_fileFormatsAvailable.size(); i++) { Tag temp = SerializedModelSaver.s_fileFormatsAvailable.get(i); m_fileFormatBox.addItem(temp); } Tag result = m_smSaver.validateFileFormat(m_smSaver.getFileFormat()); if (result == null) { m_fileFormatBox.setSelectedIndex(0); } else { m_fileFormatBox.setSelectedItem(result); } /* * m_fileFormatBox.addActionListener(new ActionListener() { public void * actionPerformed(ActionEvent e) { Tag selected = * (Tag)m_fileFormatBox.getSelectedItem(); if (selected != null) { * m_smSaver.setFileFormat(selected); } } }); */ }
/** * Validate the file format. After this bean is deserialized, classes for XML * serialization may not be in the classpath any more. * * @param ff the current file format to validate */ public Tag validateFileFormat(Tag ff) { Tag r = ff; if (ff.getID() == BINARY) { return ff; } if (ff.getID() == KOMLV && !KOML.isPresent()) { r = null; } if (ff.getID() == XSTREAM && !XStream.isPresent()) { r = null; } return r; }
/** * Returns a description of the property value as java source. * * @return a value of type 'String' */ public String getJavaInitializationString() { SelectedTag s = (SelectedTag)getValue(); Tag [] tags = s.getTags(); String result = "new SelectedTag(" + s.getSelectedTag().getID() + ", {\n"; for (int i = 0; i < tags.length; i++) { result += "new Tag(" + tags[i].getID() + ",\"" + tags[i].getReadable() + "\")"; if (i < tags.length - 1) { result += ','; } result += '\n'; } return result + "})"; }
/** * Sets the current property value as text. * * @param text the text of the selected tag. * @exception java.lang.IllegalArgumentException if an error occurs */ public void setAsText(String text) { SelectedTag s = (SelectedTag)getValue(); Tag [] tags = s.getTags(); try { for (int i = 0; i < tags.length; i++) { if (text.equals(tags[i].getReadable())) { setValue(new SelectedTag(tags[i].getID(), tags)); return; } } } catch (Exception ex) { throw new java.lang.IllegalArgumentException(text); } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions() { Enumeration enm; Vector result; result = new Vector(); enm = super.listOptions(); while (enm.hasMoreElements()) result.addElement(enm.nextElement()); result.addElement(new Option( "\tFull path to serialized classifier to include.\n" + "\tMay be specified multiple times to include\n" + "\tmultiple serialized classifiers. Note: it does\n" + "\tnot make sense to use pre-built classifiers in\n" + "\ta cross-validation.", "P", 1, "-P <path to serialized " + "classifier>")); result.addElement(new Option( "\tThe combination rule to use\n" + "\t(default: AVG)", "R", 1, "-R " + Tag.toOptionList(TAGS_RULES))); return result.elements(); }
/** * Gets an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions(){ Vector result; String desc; SelectedTag tag; int i; result = new Vector(); desc = ""; for (i = 0; i < TAGS_GUI.length; i++) { tag = new SelectedTag(TAGS_GUI[i].getID(), TAGS_GUI); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } result.addElement(new Option( "\tDetermines the layout of the GUI:\n" + desc + "\t(default: " + new SelectedTag(GUI_MDI, TAGS_GUI) + ")", "gui", 1, "-gui " + Tag.toOptionList(TAGS_GUI))); return result.elements(); }
private void setUpFileFormatComboBox() { m_fileFormatBox = new JComboBox(); for (int i = 0; i < SerializedModelSaver.s_fileFormatsAvailable.size(); i++) { Tag temp = SerializedModelSaver.s_fileFormatsAvailable.get(i); m_fileFormatBox.addItem(temp); } Tag result = m_smSaver.validateFileFormat(m_smSaver.getFileFormat()); if (result == null) { m_fileFormatBox.setSelectedIndex(0); } else { m_fileFormatBox.setSelectedItem(result); } /* m_fileFormatBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Tag selected = (Tag)m_fileFormatBox.getSelectedItem(); if (selected != null) { m_smSaver.setFileFormat(selected); } } }); */ }
/** * Validate the file format. After this bean is deserialized, classes for * XML serialization may not be in the classpath any more. * * @param ff the current file format to validate */ public Tag validateFileFormat(Tag ff) { Tag r = ff; if (ff.getID() == BINARY) { return ff; } if (ff.getID() == KOMLV && !KOML.isPresent()) { r = null; } if (ff.getID() == XSTREAM && !XStream.isPresent()) { r = null; } return r; }
/** * Gets an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result; String desc; SelectedTag tag; int i; result = new Vector<Option>(); desc = ""; for (i = 0; i < TAGS_GUI.length; i++) { tag = new SelectedTag(TAGS_GUI[i].getID(), TAGS_GUI); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } result.addElement(new Option("\tDetermines the layout of the GUI:\n" + desc + "\t(default: " + new SelectedTag(GUI_MDI, TAGS_GUI) + ")", "gui", 1, "-gui " + Tag.toOptionList(TAGS_GUI))); return result.elements(); }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions() { Enumeration enm; Vector result; result = new Vector(); enm = super.listOptions(); while (enm.hasMoreElements()) result.addElement(enm.nextElement()); result.addElement(new Option( "\tThe combination rule to use\n" + "\t(default: AVG)", "R", 1, "-R " + Tag.toOptionList(TAGS_RULES))); return result.elements(); }
/** * Gets an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration listOptions() { Vector result; String desc; SelectedTag tag; int i; result = new Vector(); desc = ""; for (i = 0; i < TAGS_GUI.length; i++) { tag = new SelectedTag(TAGS_GUI[i].getID(), TAGS_GUI); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } result.addElement(new Option(Messages.getInstance().getString( "Main_ListOptions_Option_Text_First") + desc + Messages.getInstance().getString("Main_ListOptions_Option_Text_Second") + new SelectedTag(GUI_MDI, TAGS_GUI) + ")", "gui", 1, "-gui " + Tag.toOptionList(TAGS_GUI))); return result.elements(); }
private void setUpFileFormatComboBox() { m_fileFormatBox = new JComboBox(); for (int i = 0; i < SerializedModelSaver.s_fileFormatsAvailable.size(); i++) { Tag temp = SerializedModelSaver.s_fileFormatsAvailable.get(i); m_fileFormatBox.addItem(temp); } Tag result = m_smSaver.validateFileFormat(m_smSaver.getFileFormat()); if (result == null) { m_fileFormatBox.setSelectedIndex(0); } else { m_fileFormatBox.setSelectedItem(result); } m_fileFormatBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Tag selected = (Tag)m_fileFormatBox.getSelectedItem(); if (selected != null) { m_smSaver.setFileFormat(selected); } } }); }
/** * Initializes the performance container. If the Evaluation object is null, * then the worst possible values for the measures are assumed (in order to * assure a low ranking). * * @param values the values * @param evaluation the evaluation to extract the performance * measures from, can be null * @param evalType the type of evaluation * @param classLabel the class label index (if applicable) * @param classifier the classifier * @throws Exception if retrieving of measures fails */ public Performance(Point<Object> values, AbstractEvaluationWrapper evaluation, int evalType, int classLabel, Classifier classifier) throws Exception { this(); m_Values = values; m_Evaluation = evalType; m_MetricValues = new HashMap<Integer, Double>(); m_Metrics = null; m_Classifier = classifier; if (evaluation != null) { m_Metrics = evaluation.getMetrics(); for (Tag tag : evaluation.getMetrics().getTags()) { m_MetricValues.put(tag.getID(), evaluation.getMetric(tag, classLabel)); } } }
/** * returns a string representation of this performance object. * * @return a string representation */ @Override public String toString() { String result; String evalStr; evalStr = null; if (m_Metrics != null) { for (Tag tag: m_Metrics.getTags()) { if (tag.getID() == m_Evaluation) { evalStr = tag.getIDStr(); break; } } } if (evalStr == null) evalStr = "" + m_Evaluation; result = "Performance (" + getValues() + "): "; result += getPerformance() + " (" + evalStr + ")"; return result; }
/** * generates a table string for all the performances in the space and returns * that. * * @param space the current space to align the performances to * @param performances the performances to align * @param type the type of performance * @return the table string */ public String logPerformances(Space space, Vector<Performance> performances, Tag type) { StringBuffer result; int i; result = new StringBuffer(type.getReadable() + ":\n"); result.append(space.toString()); result.append("\n"); for (i = 0; i < performances.size(); i++) { result.append(performances.get(i).getPerformance(type.getID())); result.append("\n"); } result.append("\n"); return result.toString(); }
/** * Gets the list of tags that can be selected from. * * @return an array of string tags. */ public String[] getTags() { SelectedTag s = (SelectedTag)getValue(); Tag [] tags = s.getTags(); String [] result = new String [tags.length]; for (int i = 0; i < tags.length; i++) { result[i] = tags[i].getReadable(); } return result; }
/** * Tests out the selectedtag editor from the command line. * * @param args ignored */ public static void main(String [] args) { try { GenericObjectEditor.registerEditors(); Tag [] tags = { new Tag(1, "First option"), new Tag(2, "Second option"), new Tag(3, "Third option"), new Tag(4, "Fourth option"), new Tag(5, "Fifth option"), }; SelectedTag initial = new SelectedTag(1, tags); SelectedTagEditor ce = new SelectedTagEditor(); ce.setValue(initial); PropertyValueSelector ps = new PropertyValueSelector(ce); JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(ps, BorderLayout.CENTER); f.pack(); f.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); System.err.println(ex.getMessage()); } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addElement(new Option( "\tSpecify list of string attributes to convert to words.\n" + "\t(default: select all relational attributes)", "R", 1, "-R <index1,index2-index4,...>")); result.addElement(new Option( "\tInverts the matching sense of the selection.", "V", 0, "-V")); String desc = ""; for (Tag element : TAGS_SORTTYPE) { SelectedTag tag = new SelectedTag(element.getID(), TAGS_SORTTYPE); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } result.addElement(new Option("\tDetermines the type of sorting:\n" + desc + "\t(default: " + new SelectedTag(SORT_CASESENSITIVE, TAGS_SORTTYPE) + ")", "S", 1, "-S " + Tag.toOptionList(TAGS_SORTTYPE))); result.addAll(Collections.list(super.listOptions())); return result.elements(); }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions() { Vector result; Enumeration en; String desc; int i; SelectedTag tag; result = new Vector(); en = super.listOptions(); while (en.hasMoreElements()) result.addElement(en.nextElement()); result.addElement(new Option( "\tSpecify list of string attributes to convert to words.\n" + "\t(default: select all relational attributes)", "R", 1, "-R <index1,index2-index4,...>")); result.addElement(new Option( "\tInverts the matching sense of the selection.", "V", 0, "-V")); desc = ""; for (i = 0; i < TAGS_SORTTYPE.length; i++) { tag = new SelectedTag(TAGS_SORTTYPE[i].getID(), TAGS_SORTTYPE); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } result.addElement(new Option( "\tDetermines the type of sorting:\n" + desc + "\t(default: " + new SelectedTag(SORT_CASESENSITIVE, TAGS_SORTTYPE) + ")", "S", 1, "-S " + Tag.toOptionList(TAGS_SORTTYPE))); return result.elements(); }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> newVector; String desc; SelectedTag tag; int i; newVector = new Vector<Option>(); desc = ""; for (i = 0; i < TAGS_TYPE.length; i++) { tag = new SelectedTag(TAGS_TYPE[i].getID(), TAGS_TYPE); desc += "\t" + tag.getSelectedTag().getIDStr() + " = " + tag.getSelectedTag().getReadable() + "\n"; } newVector.addElement(new Option("\tThe type of attribute to create:\n" + desc + "\t(default: " + new SelectedTag(Attribute.NUMERIC, TAGS_TYPE) + ")", "T", 1, "-T " + Tag.toOptionList(TAGS_TYPE))); newVector.addElement(new Option( "\tSpecify where to insert the column. First and last\n" + "\tare valid indexes.(default: last)", "C", 1, "-C <index>")); newVector.addElement(new Option("\tName of the new attribute.\n" + "\t(default: 'Unnamed')", "N", 1, "-N <name>")); newVector.addElement(new Option( "\tCreate nominal attribute with given labels\n" + "\t(default: numeric attribute)", "L", 1, "-L <label1,label2,...>")); newVector.addElement(new Option( "\tThe format of the date values (see ISO-8601)\n" + "\t(default: yyyy-MM-dd'T'HH:mm:ss)", "F", 1, "-F <format>")); return newVector.elements(); }
/** * returns a string containing a gnuplot script+data file * * @return the data in gnuplot format */ public String toGnuplot() { StringBuffer result; Tag type; int i; result = new StringBuffer(); type = new SelectedTag(getType(), TAGS_EVALUATION).getSelectedTag(); result.append("Gnuplot (" + type.getReadable() + "):\n"); result.append("# begin 'gridsearch.data'\n"); result.append("# " + type.getReadable() + "\n"); for (i = 0; i < getPerformances().size(); i++) result.append(getPerformances().get(i).toGnuplot(type.getID()) + "\n"); result.append("# end 'gridsearch.data'\n\n"); result.append("# begin 'gridsearch.plot'\n"); result.append("# " + type.getReadable() + "\n"); result.append("set data style lines\n"); result.append("set contour base\n"); result.append("set surface\n"); result.append("set title '" + m_Data.relationName() + "'\n"); result.append("set xrange [" + getGrid().getMinX() + ":" + getGrid().getMaxX() + "]\n"); result.append("set xlabel 'x (" + getFilter().getClass().getName() + ": " + getXProperty() + ")'\n"); result.append("set yrange [" + getGrid().getMinY() + ":" + getGrid().getMaxY() + "]\n"); result.append("set ylabel 'y - (" + getClassifier().getClass().getName() + ": " + getYProperty() + ")'\n"); result.append("set zrange [" + (getMin() - (getMax() - getMin())*0.1) + ":" + (getMax() + (getMax() - getMin())*0.1) + "]\n"); result.append("set zlabel 'z - " + type.getReadable() + "'\n"); result.append("set dgrid3d " + getGrid().height() + "," + getGrid().width() + ",1\n"); result.append("show contour\n"); result.append("splot 'gridsearch.data'\n"); result.append("pause -1\n"); result.append("# end 'gridsearch.plot'"); return result.toString(); }
/** * generates a table string for all the performances in the grid and returns * that. * * @param grid the current grid to align the performances to * @param performances the performances to align * @param type the type of performance * @return the table string */ protected String logPerformances(Grid grid, Vector<Performance> performances, Tag type) { StringBuffer result; PerformanceTable table; result = new StringBuffer(type.getReadable() + ":\n"); table = new PerformanceTable(grid, performances, type.getID()); result.append(table.toString() + "\n"); result.append("\n"); result.append(table.toGnuplot() + "\n"); result.append("\n"); return result.toString(); }
/** * Tests out the selectedtag editor from the command line. * * @param args ignored */ public static void main(String [] args) { try { GenericObjectEditor.registerEditors(); Tag [] tags = { new Tag(1, Messages.getInstance().getString("SelectedTagEditor_Main_Tags_Text_First")), new Tag(2, Messages.getInstance().getString("SelectedTagEditor_Main_Tags_Text_Second")), new Tag(3, Messages.getInstance().getString("SelectedTagEditor_Main_Tags_Text_Third")), new Tag(4, Messages.getInstance().getString("SelectedTagEditor_Main_Tags_Text_Fourth")), new Tag(5, Messages.getInstance().getString("SelectedTagEditor_Main_Tags_Text_Fifth")), }; SelectedTag initial = new SelectedTag(1, tags); SelectedTagEditor ce = new SelectedTagEditor(); ce.setValue(initial); PropertyValueSelector ps = new PropertyValueSelector(ce); JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(ps, BorderLayout.CENTER); f.pack(); f.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); System.err.println(ex.getMessage()); } }