Package weka.core

Examples of weka.core.DenseInstance


      for (int i = incoming.numAttributes(); i < incoming.numAttributes()
          + (m_fieldsToForecast.size() * 2); i++) {
        values[i] = Utils.missingValue();
      }

      output = new DenseInstance(1.0, values);
    }
    output.setDataset(m_outgoingStructure);

    return output;
  }
View Full Code Here


  }

  @Override
  public void execute(Tuple input) {
    //Get the instance
    DenseInstance inst = (DenseInstance) input.getValue(0);
    INST_HEADERS = inst.dataset();
   
    //Retrieve the semaphore
    try {
      semaphore.acquire();
    } catch (InterruptedException e2) {
View Full Code Here

  @Override
  public void execute(Tuple input) {
    //Get the post
    Post newPost = (Post)input.getValue(0);
    //Turn it into an instance
    Instance inst = new DenseInstance(2);
    inst.setDataset(INST_HEADERS);
    inst.setValue(0, newPost.getTitle());
    inst.setValue(1, newPost.getSubReddit());
    //emit these to a new bolt that collects instances
    _collector.emit(new Values(inst));
    _collector.ack(input);
  }
View Full Code Here

         ArrayList<String> values = mapValues.get(strName);
         vals[j] = values.indexOf(strTemp);
            }

      // add
      data.add(new DenseInstance(1.0, vals));  
       
     
    
     //2.4. set class attribute
    for( Integer j = 0; j < u.n; j++) {
View Full Code Here

          
           vals[j++] = values.indexOf(d);   
          }
         
          // add
        data.add(new DenseInstance(1.0, vals));  
       }
    }
         
     //2.4. set class attribute
    int j = 0;
View Full Code Here

        vals[i] = values.indexOf(strData);
        i++;
      }
     
      // add
      data.add(new DenseInstance(1.0, vals));  
    }
   
    //2.4. set class attribute
      data.setClassIndex(data.numAttributes() - 3);
   
View Full Code Here

        assertEquals(0.0, result, .1);
    }
   
    private Instance createInstance(Instances dataset, Object... parameters)
    {
        Instance instance = new DenseInstance(5);
        instance.setDataset(dataset);
        for (int i=0; i<parameters.length; i++)
        {
            Object obj = parameters[i];
            if (obj instanceof Number)
            {
                instance.setValue(i, ((Number)obj).doubleValue());
            }
            else if (obj == Null.getValue())
            {
                instance.setMissing(i);
            }
            else
            {
                instance.setValue(i, obj.toString());
            }
        }
        return instance;
    }
View Full Code Here

   * @param attrs list of attribute types of this entry
   * @param list  list of attribute values of this entry
   * @return
   */
  public static Instance newInstance(ArrayList<Attribute> attrs, Object ...list){
    Instance newInstance = new DenseInstance(list.length);
   
    Attribute att;
    for(int i=0; i<attrs.size(); i++){
         att = attrs.get(i);
         String listval = list[i].toString();

        // System.out.println(" ATTR. " + att + " VAL. " + listval);
         if(att.isNumeric()){
           try
             double dval = Double.parseDouble(listval);
             newInstance.setValue(att, dval );
           }catch(Exception ex){  }
         }
         else{
           try{
             newInstance.setValue(att, list[i].toString() );
           }catch(Exception e){
             e.printStackTrace();
          
         }
    }
View Full Code Here

   * @param inst instance to add
   * @return the new dataset
   */
  public  static Instances addInstance(Instances bb, Object ...list){
   
    Instance newInstance = new DenseInstance(list.length);
   
    Attribute att;
    for(int i=0; i<bb.numAttributes(); i++){
         att = bb.attribute(i);
         String listval = list[i].toString();

         //System.out.println(" ATTR. " + att + " VAL. " + listval);
         if(att.isNumeric()){
           try
             double dval = Double.parseDouble(listval);
             newInstance.setValue(att, dval );
           }catch(Exception ex){  }
         }
         else{
           try{
             newInstance.setValue(att, list[i].toString() );
           }catch(Exception e){
             e.printStackTrace();
          
         }
    }
View Full Code Here

       duration = (endTime - startTime)/1000F;
      
       System.out.println("\nElapsed time: "+(duration)+"sec");

      //test on instance
       Instance instance = new DenseInstance(4);
       instance.setValue(data.attribute("Abilities"), "pediatrician");
       instance.setValue(data.attribute("Dispositions"), "cautious");
       instance.setValue(data.attribute("Cross"), "female");
       instance.setDataset(data);
      
       classifier.testInstance(instance);
      
       System.out.println(instance);
      
View Full Code Here

TOP

Related Classes of weka.core.DenseInstance

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.