*/
protected void loadClusterer() {
int returnVal = m_FileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File selected = m_FileChooser.getSelectedFile();
Clusterer clusterer = null;
Instances trainHeader = null;
int[] ignoredAtts = null;
m_Log.statusMessage("Loading model from file...");
try {
InputStream is = new FileInputStream(selected);
if (selected.getName().endsWith(".gz")) {
is = new GZIPInputStream(is);
}
ObjectInputStream objectInputStream = new ObjectInputStream(is);
clusterer = (Clusterer) objectInputStream.readObject();
try { // see if we can load the header & ignored attribute info
trainHeader = (Instances) objectInputStream.readObject();
ignoredAtts = (int[]) objectInputStream.readObject();
} catch (Exception e) {} // don't fuss if we can't
objectInputStream.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Load Failed",
JOptionPane.ERROR_MESSAGE);
}
m_Log.statusMessage("OK");
if (clusterer != null) {
m_Log.logMessage("Loaded model from file '" + selected.getName()+ "'");
String name = (new SimpleDateFormat("HH:mm:ss - ")).format(new Date());
String cname = clusterer.getClass().getName();
if (cname.startsWith("weka.clusterers."))
cname = cname.substring("weka.clusterers.".length());
name += cname + " from file '" + selected.getName() + "'";
StringBuffer outBuff = new StringBuffer();
outBuff.append("=== Model information ===\n\n");
outBuff.append("Filename: " + selected.getName() + "\n");
outBuff.append("Scheme: " + clusterer.getClass().getName());
if (clusterer instanceof OptionHandler) {
String [] o = ((OptionHandler) clusterer).getOptions();
outBuff.append(" " + Utils.joinOptions(o));
}