Package weka.clusterers

Examples of weka.clusterers.Clusterer


    m_ClustererEditor.setValue(ExplorerDefaults.getClusterer());
    m_ClustererEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
        m_StartBut.setEnabled(true);
        Capabilities currentFilter = m_ClustererEditor.getCapabilitiesFilter();
        Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
        Capabilities currentSchemeCapabilities =  null;
        if (clusterer != null && currentFilter != null &&
            (clusterer instanceof CapabilitiesHandler)) {
          currentSchemeCapabilities = ((CapabilitiesHandler)clusterer).getCapabilities();
         
View Full Code Here


    String grph = null;
    int[] ignoredAtts = null;

    int testMode = 0;
    int percent = 66;
    Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
    Clusterer fullClusterer = null;
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - ")).format(new Date());
    String cname = clusterer.getClass().getName();
    if (cname.startsWith("weka.clusterers.")) {
      name += cname.substring("weka.clusterers.".length());
View Full Code Here

      o = (FastVector)m_History.getNamedObject(selectedName);
    }

    VisualizePanel temp_vp = null;
    String temp_grph = null;
    Clusterer temp_clusterer = null;
    Instances temp_trainHeader = null;
    int[] temp_ignoreAtts = null;
   
    if (o != null) {
      for (int i = 0; i < o.size(); i++) {
  Object temp = o.elementAt(i);
  if (temp instanceof Clusterer) {
    temp_clusterer = (Clusterer)temp;
  } else if (temp instanceof Instances) { // training header
    temp_trainHeader = (Instances)temp;
  } else if (temp instanceof int[]) { // ignored attributes
    temp_ignoreAtts = (int[])temp;
  } else if (temp instanceof VisualizePanel) { // normal errors
    temp_vp = (VisualizePanel)temp;
  } else if (temp instanceof String) { // graphable output
    temp_grph = (String)temp;
  }
      }
    }
     
    final VisualizePanel vp = temp_vp;
    final String grph = temp_grph;
    final Clusterer clusterer = temp_clusterer;
    final Instances trainHeader = temp_trainHeader;
    final int[] ignoreAtts = temp_ignoreAtts;
   
    JMenuItem saveModel = new JMenuItem("Save model");
    if (clusterer != null) {
View Full Code Here

  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));
  }
  outBuff.append("\n");

  if (trainHeader != null) {

    outBuff.append("Relation:     " + trainHeader.relationName() + '\n');
    outBuff.append("Attributes:   " + trainHeader.numAttributes() + '\n');
    if (trainHeader.numAttributes() < 100) {
      boolean [] selectedAtts = new boolean [trainHeader.numAttributes()];
      for (int i = 0; i < trainHeader.numAttributes(); i++) {
        selectedAtts[i] = true;
      }
     
      if (ignoredAtts != null)
        for (int i=0; i<ignoredAtts.length; i++)
    selectedAtts[ignoredAtts[i]] = false;
    
      for (int i = 0; i < trainHeader.numAttributes(); i++) {
        if (selectedAtts[i]) {
    outBuff.append("              " + trainHeader.attribute(i).name()
             + '\n');
        }
      }
      if (ignoredAtts != null) {
        outBuff.append("Ignored:\n");
        for (int i=0; i<ignoredAtts.length; i++)
    outBuff.append("              "
             + trainHeader.attribute(ignoredAtts[i]).name()
             + '\n');
      }
    } else {
      outBuff.append("              [list of attributes omitted]\n");
    }
  } else {
    outBuff.append("\nTraining data unknown\n");
  }
 
  outBuff.append("\n=== Clustering model ===\n\n");
  outBuff.append(clusterer.toString() + "\n");

  m_History.addResult(name, outBuff);
  m_History.setSingle(name);
  FastVector vv = new FastVector();
  vv.addElement(clusterer);
View Full Code Here

    m_ClustererEditor.setCapabilitiesFilter(filterClass);
   
    // check capabilities
    m_StartBut.setEnabled(true);
    Capabilities currentFilter = m_ClustererEditor.getCapabilitiesFilter();
    Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
    Capabilities currentSchemeCapabilities =  null;
    if (clusterer != null && currentFilter != null &&
        (clusterer instanceof CapabilitiesHandler)) {
      currentSchemeCapabilities = ((CapabilitiesHandler)clusterer).getCapabilities();
     
View Full Code Here

    m_ClustererEditor.setValue(ExplorerDefaults.getClusterer());
    m_ClustererEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
        m_StartBut.setEnabled(true);
        Capabilities currentFilter = m_ClustererEditor.getCapabilitiesFilter();
        Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
        Capabilities currentSchemeCapabilities =  null;
        if (clusterer != null && currentFilter != null &&
            (clusterer instanceof CapabilitiesHandler)) {
          currentSchemeCapabilities = ((CapabilitiesHandler)clusterer).getCapabilities();
         
View Full Code Here

    String grph = null;
    int[] ignoredAtts = null;

    int testMode = 0;
    int percent = 66;
    Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
    Clusterer fullClusterer = null;
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - "))
    .format(new Date());
    String cname = clusterer.getClass().getName();
    if (cname.startsWith("weka.clusterers.")) {
View Full Code Here

      o = (FastVector)m_History.getNamedObject(selectedName);
    }

    VisualizePanel temp_vp = null;
    String temp_grph = null;
    Clusterer temp_clusterer = null;
    Instances temp_trainHeader = null;
    int[] temp_ignoreAtts = null;
   
    if (o != null) {
      for (int i = 0; i < o.size(); i++) {
  Object temp = o.elementAt(i);
  if (temp instanceof Clusterer) {
    temp_clusterer = (Clusterer)temp;
  } else if (temp instanceof Instances) { // training header
    temp_trainHeader = (Instances)temp;
  } else if (temp instanceof int[]) { // ignored attributes
    temp_ignoreAtts = (int[])temp;
  } else if (temp instanceof VisualizePanel) { // normal errors
    temp_vp = (VisualizePanel)temp;
  } else if (temp instanceof String) { // graphable output
    temp_grph = (String)temp;
  }
      }
    }
     
    final VisualizePanel vp = temp_vp;
    final String grph = temp_grph;
    final Clusterer clusterer = temp_clusterer;
    final Instances trainHeader = temp_trainHeader;
    final int[] ignoreAtts = temp_ignoreAtts;
   
    JMenuItem saveModel = new JMenuItem(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_SaveModel_JMenuItem_Text"));
    if (clusterer != null) {
View Full Code Here

  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(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_Log_StatusSessage_Text_First"));

      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, Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_JOptionPaneShowMessageDialog_Text"),
              JOptionPane.ERROR_MESSAGE);
     

      m_Log.statusMessage(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_Log_StatusMessage_Text_Second"));
     
      if (clusterer != null) {
  m_Log.logMessage(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_Log_LogMessage_Text_First") + 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 + Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_CNAme_Text_First") + selected.getName() + "'";
  StringBuffer outBuff = new StringBuffer();

  outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_First"));
  outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Second") + selected.getName() + "\n");
  outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Fourth") + clusterer.getClass().getName());
  if (clusterer instanceof OptionHandler) {
    String [] o = ((OptionHandler) clusterer).getOptions();
    outBuff.append(" " + Utils.joinOptions(o));
  }
  outBuff.append("\n");

  if (trainHeader != null) {

    outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Sixth") + trainHeader.relationName() + '\n');
    outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Eighth") + trainHeader.numAttributes() + '\n');
    if (trainHeader.numAttributes() < 100) {
      boolean [] selectedAtts = new boolean [trainHeader.numAttributes()];
      for (int i = 0; i < trainHeader.numAttributes(); i++) {
        selectedAtts[i] = true;
      }
     
      if (ignoredAtts != null)
        for (int i=0; i<ignoredAtts.length; i++)
    selectedAtts[ignoredAtts[i]] = false;
    
      for (int i = 0; i < trainHeader.numAttributes(); i++) {
        if (selectedAtts[i]) {
    outBuff.append("              " + trainHeader.attribute(i).name()
             + '\n');
        }
      }
      if (ignoredAtts != null) {
        outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Eleventh"));
        for (int i=0; i<ignoredAtts.length; i++)
    outBuff.append("              "
             + trainHeader.attribute(ignoredAtts[i]).name()
             + '\n');
      }
    } else {
      outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Twelveth"));
    }
  } else {
    outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Thirteenth"));
  }
 
  outBuff.append(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_LoadClusterer_OutBuffer_Text_Fourteenth"));
  outBuff.append(clusterer.toString() + "\n");

  m_History.addResult(name, outBuff);
  m_History.setSingle(name);
  FastVector vv = new FastVector();
  vv.addElement(clusterer);
View Full Code Here

    m_ClustererEditor.setCapabilitiesFilter(filterClass);

    // check capabilities
    m_StartBut.setEnabled(true);
    Capabilities currentFilter = m_ClustererEditor.getCapabilitiesFilter();
    Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
    Capabilities currentSchemeCapabilities =  null;
    if (clusterer != null && currentFilter != null &&
        (clusterer instanceof CapabilitiesHandler)) {
      currentSchemeCapabilities = ((CapabilitiesHandler)clusterer).getCapabilities();
         
View Full Code Here

TOP

Related Classes of weka.clusterers.Clusterer

Copyright © 2018 www.massapicom. 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.