Package weka.core

Examples of weka.core.Attribute

Typical usage (code from the main() method of this class):

...
// Create numeric attributes "length" and "weight"
Attribute length = new Attribute("length");
Attribute weight = new Attribute("weight");

// Create list to hold nominal values "first", "second", "third"
List my_nominal_values = new ArrayList(3);
my_nominal_values.add("first");
my_nominal_values.add("second");
my_nominal_values.add("third");

// Create nominal attribute "position"
Attribute position = new Attribute("position", my_nominal_values);
...

@author Eibe Frank (eibe@cs.waikato.ac.nz) @version $Revision: 6889 $


  public Instance getInstance(Properties ontoProperties, OWLOntology ontology, Query query){
    List<String> featureList = getFeatures(ontoProperties, ontology, query);
    Instance instance = new Instance(featureList.size() + 1);
    instance.setDataset(dataset);
    for(int i = 0; i < featureList.size(); i ++){
      Attribute attr = instance.attribute(i);
      if(attr.isNumeric()){
        instance.setValue(i, Double.valueOf(featureList.get(i)));
      }else{
        instance.setValue(i, featureList.get(i));
      }
    }
View Full Code Here


  public void TestCreateInstances1()
  {
    int attributeNumber = 4;
    FastVector vecA = new FastVector(3);vecA.addElement(WekaDataCollector.MINUSONE);vecA.addElement(WekaDataCollector.ZERO);vecA.addElement(WekaDataCollector.ONE);
    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

      //Build the classifier
      //Generating attributes
      FastVector fvWekaAttributes = new FastVector(features.size()+1);     
      for(String feature:features)
      {
        fvWekaAttributes.addElement(new Attribute(feature));
      }
      fvWekaAttributes.addElement(new Attribute("Sense",fvClassVal));
     
      //Generating the class attribute
       // Create an empty training set
       ins = new Instances(target.getLemma(), fvWekaAttributes,  totalsamples);
      
View Full Code Here

      {
        c[i]=0;
      }
      for(int i=0;i<base.numAttributes();i++)
      {
        Attribute att=base.attribute(i);       
        for(AmbiguousWord word:window)
         {
           if(word.getLemma().equals(att.name()))
           {
             c[i]++; 
           }
         }
      }
View Full Code Here

   * Begins construction of an instance of pair classifier.
   */
  public WekaDataCollector()
  {
    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    classAttribute = new Attribute("class",vecBool);
  }
View Full Code Here

   
    protected PairRankingSupport(String name, String [] range)
    {
      FastVector vecA = new FastVector(3);
      for(String v:range) vecA.addElement(v);
      att = new Attribute(name,vecA);
    }
View Full Code Here

   * Begins construction of an instance of pair classifier.
   */
  public WekaDataCollector()
  {
    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    classAttribute = new Attribute("class",vecBool);
  }
View Full Code Here

   
    protected PairRankingSupport(String name, String [] range)
    {
      FastVector vecA = new FastVector(3);
      for(String v:range) vecA.addElement(v);
      att = new Attribute(name,vecA);
    }
View Full Code Here

  public void TestCreateInstances1()
  {
    int attributeNumber = 4;
    FastVector vecA = new FastVector(3);vecA.addElement(WekaDataCollector.MINUSONE);vecA.addElement(WekaDataCollector.ZERO);vecA.addElement(WekaDataCollector.ONE);
    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

  public void TestCreateInstances1()
  {
    int attributeNumber = 4;
    FastVector vecA = new FastVector(3);vecA.addElement(WekaDataCollector.MINUSONE);vecA.addElement(WekaDataCollector.ZERO);vecA.addElement(WekaDataCollector.ONE);
    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

TOP

Related Classes of weka.core.Attribute

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.