Package weka.associations

Examples of weka.associations.Associator


        Map<Integer, List<Object>> nominalValues =
            getNominalValues(iterationInputs, metadata);
        Instances dataset = WekaUtilities.createAssociationDataset(tuples, nominalValues);
        String options = TupleUtilities.getAsString(iterationInputs[1], INPUT_OPTIONS);
        String algorithmClass = TupleUtilities.getAsString(iterationInputs[2], INPUT_ALGORITHM_CLASS);
        Associator associator;
        try
        {
          associator = loadAssociator(options, algorithmClass);
            TupleAssociator tupleAssociator =
                new TupleAssociator(
                        associator,
                        WekaUtilities.getAttributes(dataset));
          
            associator.buildAssociations(dataset);
            mOutputAssociator.write(tupleAssociator.getAssociator());
            if(mOutputRules != null)
              mOutputRules.write(tupleAssociator.getAssociator().toString());
           
        }
View Full Code Here


     
   

    try
    {
    Associator assoc = (Associator)Associator.class.forName(algorithmClass).newInstance();
   
    LOG.debug("Associator: " + mAssociatorName);
      if(options == null || options == "")
        options = DEFAULT_OPTIONS;
    String[] opt = weka.core.Utils.splitOptions(options);
View Full Code Here

        Map<Integer, List<Object>> nominalValues =
            getNominalValues(iterationInputs, metadata);
        Instances dataset = WekaUtilities.createAssociationDataset(tuples, nominalValues);
        String options = TupleUtilities.getAsString(iterationInputs[1], INPUT_OPTIONS);
        String algorithmClass = TupleUtilities.getAsString(iterationInputs[2], INPUT_ALGORITHM_CLASS);
        Associator associator;
        try
        {
          associator = loadAssociator(options, algorithmClass);
          if(associator instanceof Apriori) {
            ((Apriori)associator).setTreatZeroAsMissing(true);

          }
            TupleAssociator tupleAssociator =
                new TupleAssociator(
                        associator,
                        WekaUtilities.getAttributes(dataset));
          
            associator.buildAssociations(dataset);
            mOutputAssociator.write(ControlBlock.LIST_BEGIN);
            mOutputAssociator.write(tupleAssociator.getAssociator());
            mOutputAssociator.write(ControlBlock.LIST_END);
            if(mOutputRules != null && ((AssociationRulesProducer)tupleAssociator.getAssociator()).getAssociationRules().getRules().size() > 0 ) {
              mOutputRules.write(ControlBlock.LIST_BEGIN);
View Full Code Here

     
   

    try
    {
    Associator assoc = (Associator)Associator.class.forName(algorithmClass).newInstance();
    LOG.debug("Associator: " + mAssociatorName);
      if(options == null || options == "")
        options = DEFAULT_OPTIONS;
    String[] opt = weka.core.Utils.splitOptions(options);
    ((OptionHandler)assoc).setOptions(opt);
View Full Code Here

    m_AssociatorEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
        m_StartBut.setEnabled(true);
        // Check capabilities
        Capabilities currentFilter = m_AssociatorEditor.getCapabilitiesFilter();
        Associator associator = (Associator) m_AssociatorEditor.getValue();
        Capabilities currentSchemeCapabilities =  null;
        if (associator != null && currentFilter != null &&
            (associator instanceof CapabilitiesHandler)) {
          currentSchemeCapabilities = ((CapabilitiesHandler)associator).getCapabilities();
         
View Full Code Here

  public void run() {
    // Copy the current state of things
    m_Log.statusMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_StatusMessage_Text_First"));
    Instances inst = new Instances(m_Instances);

    Associator associator = (Associator) m_AssociatorEditor.getValue();
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - "))
    .format(new Date());
    String cname = associator.getClass().getName();
    if (cname.startsWith("weka.associations.")) {
      name += cname.substring("weka.associations.".length());
    } else {
      name += cname;
    }
          String cmd = m_AssociatorEditor.getValue().getClass().getName();
          if (m_AssociatorEditor.getValue() instanceof OptionHandler)
            cmd += " " + Utils.joinOptions(((OptionHandler) m_AssociatorEditor.getValue()).getOptions());
    try {

      // Output some header information
      m_Log.logMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_LogMessage_Text_First") + cname);
      m_Log.logMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_LogMessage_Text_Second") + cmd);
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskStarted();
      }
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_First"));
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Second") + cname);
      if (associator instanceof OptionHandler) {
        String [] o = ((OptionHandler) associator).getOptions();
        outBuff.append(" " + Utils.joinOptions(o));
      }
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Third"));
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Fourth") + inst.relationName() + '\n');
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Sixth") + inst.numInstances() + '\n');
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Seventh") + inst.numAttributes() + '\n');
      if (inst.numAttributes() < 100) {
        for (int i = 0; i < inst.numAttributes(); i++) {
    outBuff.append("              " + inst.attribute(i).name()
             + '\n');
        }
      } else {
        outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Eighth"));
      }
      m_History.addResult(name, outBuff);
      m_History.setSingle(name);
     
      // Build the model and output it.
      m_Log.statusMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_StatusMessage_Text_Second"));
      associator.buildAssociations(inst);
      outBuff.append(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_OutBuffer_Text_Nineth"));
      outBuff.append(associator.toString() + '\n');
      m_History.updateResult(name);
      m_Log.logMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_LogMessage_Text_Third") + cname);
      m_Log.statusMessage(Messages.getInstance().getString("AssociationsPanel_StartAssociator_Run_Log_StatusMessage_Text_Third"));
    } catch (Exception ex) {
      m_Log.logMessage(ex.getMessage());
View Full Code Here

    m_AssociatorEditor.setCapabilitiesFilter(filterClass);
   
    m_StartBut.setEnabled(true);
    // Check capabilities
    Capabilities currentFilter = m_AssociatorEditor.getCapabilitiesFilter();
    Associator associator = (Associator) m_AssociatorEditor.getValue();
    Capabilities currentSchemeCapabilities =  null;
    if (associator != null && currentFilter != null &&
        (associator instanceof CapabilitiesHandler)) {
      currentSchemeCapabilities = ((CapabilitiesHandler)associator).getCapabilities();
     
View Full Code Here

  public void run() {
    // Copy the current state of things
    m_Log.statusMessage("Setting up...");
    Instances inst = new Instances(m_Instances);

    Associator associator = (Associator) m_AssociatorEditor.getValue();
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - "))
    .format(new Date());
    String cname = associator.getClass().getName();
    if (cname.startsWith("weka.associations.")) {
      name += cname.substring("weka.associations.".length());
    } else {
      name += cname;
    }
          String cmd = m_AssociatorEditor.getValue().getClass().getName();
          if (m_AssociatorEditor.getValue() instanceof OptionHandler)
            cmd += " " + Utils.joinOptions(((OptionHandler) m_AssociatorEditor.getValue()).getOptions());
    try {

      // Output some header information
      m_Log.logMessage("Started " + cname);
      m_Log.logMessage("Command: " + cmd);
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskStarted();
      }
      outBuff.append("=== Run information ===\n\n");
      outBuff.append("Scheme:       " + cname);
      if (associator instanceof OptionHandler) {
        String [] o = ((OptionHandler) associator).getOptions();
        outBuff.append(" " + Utils.joinOptions(o));
      }
      outBuff.append("\n");
      outBuff.append("Relation:     " + inst.relationName() + '\n');
      outBuff.append("Instances:    " + inst.numInstances() + '\n');
      outBuff.append("Attributes:   " + inst.numAttributes() + '\n');
      if (inst.numAttributes() < 100) {
        for (int i = 0; i < inst.numAttributes(); i++) {
    outBuff.append("              " + inst.attribute(i).name()
             + '\n');
        }
      } else {
        outBuff.append("              [list of attributes omitted]\n");
      }
      m_History.addResult(name, outBuff);
      m_History.setSingle(name);
     
      // Build the model and output it.
      m_Log.statusMessage("Building model on training data...");
      associator.buildAssociations(inst);
      outBuff.append("=== Associator model (full training set) ===\n\n");
      outBuff.append(associator.toString() + '\n');
      m_History.updateResult(name);
      m_Log.logMessage("Finished " + cname);
      m_Log.statusMessage("OK");
    } catch (Exception ex) {
      m_Log.logMessage(ex.getMessage());
View Full Code Here

    m_AssociatorEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
        m_StartBut.setEnabled(true);
        // Check capabilities
        Capabilities currentFilter = m_AssociatorEditor.getCapabilitiesFilter();
        Associator associator = (Associator) m_AssociatorEditor.getValue();
        Capabilities currentSchemeCapabilities =  null;
        if (associator != null && currentFilter != null &&
            (associator instanceof CapabilitiesHandler)) {
          currentSchemeCapabilities = ((CapabilitiesHandler)associator).getCapabilities();
         
View Full Code Here

    m_Log.statusMessage("Setting up...");
    Instances inst = new Instances(m_Instances);
    String grph = null;
    //String xmlRules = null;
    AssociationRules rulesList = null;
    Associator associator = (Associator) m_AssociatorEditor.getValue();
    StringBuffer outBuff = new StringBuffer();
    String name = (new SimpleDateFormat("HH:mm:ss - "))
    .format(new Date());
    String cname = associator.getClass().getName();
    if (cname.startsWith("weka.associations.")) {
      name += cname.substring("weka.associations.".length());
    } else {
      name += cname;
    }
          String cmd = m_AssociatorEditor.getValue().getClass().getName();
          if (m_AssociatorEditor.getValue() instanceof OptionHandler)
            cmd += " " + Utils.joinOptions(((OptionHandler) m_AssociatorEditor.getValue()).getOptions());
    try {

      // Output some header information
      m_Log.logMessage("Started " + cname);
      m_Log.logMessage("Command: " + cmd);
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskStarted();
      }
      outBuff.append("=== Run information ===\n\n");
      outBuff.append("Scheme:       " + cname);
      if (associator instanceof OptionHandler) {
        String [] o = ((OptionHandler) associator).getOptions();
        outBuff.append(" " + Utils.joinOptions(o));
      }
      outBuff.append("\n");
      outBuff.append("Relation:     " + inst.relationName() + '\n');
      outBuff.append("Instances:    " + inst.numInstances() + '\n');
      outBuff.append("Attributes:   " + inst.numAttributes() + '\n');
      if (inst.numAttributes() < 100) {
        for (int i = 0; i < inst.numAttributes(); i++) {
    outBuff.append("              " + inst.attribute(i).name()
             + '\n');
        }
      } else {
        outBuff.append("              [list of attributes omitted]\n");
      }
      m_History.addResult(name, outBuff);
      m_History.setSingle(name);
     
      // Build the model and output it.
      m_Log.statusMessage("Building model on training data...");
      associator.buildAssociations(inst);
      outBuff.append("=== Associator model (full training set) ===\n\n");
      outBuff.append(associator.toString() + '\n');
      m_History.updateResult(name);
      if (m_storeOutput.isSelected()) {
        if (associator instanceof Drawable) {
          grph = null;
          try {
View Full Code Here

TOP

Related Classes of weka.associations.Associator

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.