Package weka.core

Examples of weka.core.DenseInstance


    }
    for(int j=0, numInsts=list1.length()+list2.length();
        j < attrVals.length; j++) {
      attrVals[j] /= numInsts;
    }
    temp = new DenseInstance(1.0, attrVals);
    return temp;
  }
View Full Code Here


    for(int k=0; k<node2.anchor.numValues(); k++) {
      if(node2.anchor.index(k)==classIdx)
  continue;
      attrVals[k] += node2.anchor.valueSparse(k)*anchr2Ratio;
    }
    temp = new DenseInstance(1.0, attrVals);
    return temp;
  }
View Full Code Here

    if (m_RP != rp) {
      throw new Error("Unrecognized ResultProducer sending results!!");
    }
   
    Instance newInst = new DenseInstance(m_AttributeTypes.length);
    for(int i = 0; i < m_AttributeTypes.length; i++) {
      Object val = null;
      if (i < key.length) {
  val = key[i];
      } else {
  val = result[i - key.length];
      }
      if (val == null) {
  newInst.setValue(i, Utils.missingValue());
      } else {
  switch (m_AttributeTypes[i]) {
  case Attribute.NOMINAL:
    String str = (String) val;
    Double index = (Double)m_NominalIndexes[i].get(str);
    if (index == null) {
      index = new Double(m_NominalStrings[i].size());
      m_NominalIndexes[i].put(str, index);
      m_NominalStrings[i].addElement(str);
    }
    newInst.setValue(i, index.doubleValue());
    break;
  case Attribute.NUMERIC:
    double dou = ((Double) val).doubleValue();
    newInst.setValue(i, (double)dou);
    break;
  default:
    newInst.setValue(i, Utils.missingValue());
  }
      }
    }
    m_Instances.addElement(newInst);
  }
View Full Code Here

            }
        }
       
        for (int iInstance = 0; iInstance < bayesNet.m_Instances.numInstances(); iInstance++) {
            Instance instanceOrig = bayesNet.m_Instances.instance(iInstance);
            Instance instance = new DenseInstance(instances.numAttributes());
            for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
                if (iAttribute != instances.classIndex()) {
                    if (instanceOrig.value(iAttribute) > 0) {
                        instance.setValue(iAttribute, 1);
                    }
                } else {
                    instance.setValue(iAttribute, instanceOrig.value(iAttribute));
                }
            }
        }
        // ok, now all data is binary, except the class attribute
        // now learn the empty and tree network
View Full Code Here

            vals2[j] = Math.sqrt(tempI[i].variance(j));
          } else {
            vals2[j] = Utils.missingValue();
         
        }   
        m_ClusterStdDevs.add(new DenseInstance(1.0, vals2));
      }
      m_ClusterSizes[i] = tempI[i].numInstances();
    }
  }
View Full Code Here

          }
        }
      }
    }
    if (updateClusterInfo)
      m_ClusterCentroids.add(new DenseInstance(1.0, vals));
    return vals;
  }
View Full Code Here

   */
  public void generateInstances () throws Exception {
      int [] order = getOrder();
    for (int iInstance = 0; iInstance < m_nNrOfInstances; iInstance++) {
        int nNrOfAtts = m_Instances.numAttributes();
      Instance instance = new DenseInstance(nNrOfAtts);
      instance.setDataset(m_Instances);
      for (int iAtt2 = 0; iAtt2 < nNrOfAtts; iAtt2++) {
          int iAtt = order[iAtt2];

        double iCPT = 0;

        for (int iParent = 0; iParent < m_ParentSets[iAtt].getNrOfParents(); iParent++) {
          int nParent = m_ParentSets[iAtt].getParent(iParent);
          iCPT = iCPT * m_Instances.attribute(nParent).numValues() + instance.value(nParent);
        }
 
        double fRandom = random.nextInt(1000) / 1000.0f;
        int iValue = 0;
        while (fRandom > m_Distributions[iAtt][(int) iCPT].getProbability(iValue)) {
          fRandom = fRandom - m_Distributions[iAtt][(int) iCPT].getProbability(iValue);
          iValue++ ;
        }
        instance.setValue(iAtt, iValue);
      }
      m_Instances.add(instance);
    }
  } // GenerateInstances
View Full Code Here

   
    Instance inst = null;
    if (instance instanceof SparseInstance) {
      inst = new SparseInstance(instance.weight(), vals);
    } else {
      inst = new DenseInstance(instance.weight(), vals);
    }
    inst.setDataset(getOutputFormat());
    copyValues(inst, false, instance.dataset(), getOutputFormat());
    inst.setDataset(getOutputFormat());
    push(inst);
View Full Code Here

    }
    Instance inst = null;
    if (dest instanceof SparseInstance) {
      inst = new SparseInstance(dest.weight(), vals);
    } else {
      inst = new DenseInstance(dest.weight(), vals);
    }
    inst.setDataset(dest.dataset());
    return inst;
  }
View Full Code Here

    }
    Instance inst = null;
    if (instance instanceof SparseInstance) {
      inst = new SparseInstance(instance.weight(), vals);
    } else {
      inst = new DenseInstance(instance.weight(), vals);
    }
    inst.setDataset(getOutputFormat());
    copyValues(inst, false, instance.dataset(), getOutputFormat());
    inst.setDataset(getOutputFormat());
    push(inst);
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.