List of usage examples for weka.core Instance hasMissingValue
public boolean hasMissingValue();
From source file:cerebro.Id3.java
License:Open Source License
/** * Classifies a given test instance using the decision tree. * * @param instance the instance to be classified * @return the classification/*from w w w.j a v a 2s . c o m*/ * @throws NoSupportForMissingValuesException if instance has missing values */ public double classifyInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Id3: no missing values, " + "please."); } if (m_Attribute == null) { return m_ClassValue; } else { return m_Successors[(int) instance.value(m_Attribute)].classifyInstance(instance); } }
From source file:cerebro.Id3.java
License:Open Source License
/** * Computes class distribution for instance using decision tree. * * @param instance the instance for which distribution is to be computed * @return the class distribution for the given instance * @throws NoSupportForMissingValuesException if instance has missing values *//* ww w . j av a 2s . c o m*/ public double[] distributionForInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Id3: no missing values, " + "please."); } if (m_Attribute == null) { return m_Distribution; } else { return m_Successors[(int) instance.value(m_Attribute)].distributionForInstance(instance); } }
From source file:decisiontree.MyID3.java
@Override public double classifyInstance(Instance instance) throws Exception { if (instance.hasMissingValue()) { throw new Exception("Can't handle missing value(s)"); }/*www. jav a 2s . c om*/ if (splitAttr == null) { if (Utils.eq(leafValue, Double.NaN)) { return instance.value(classAttr); } else { return leafValue; } } else { return child[(int) instance.value(splitAttr)].classifyInstance(instance); } }
From source file:decisiontree.MyID3.java
@Override public double[] distributionForInstance(Instance instance) throws Exception { if (instance.hasMissingValue()) { throw new Exception("Can't handle missing value(s)"); }/*from w w w .jav a 2s.co m*/ if (splitAttr == null) { return leafDist; } else { return child[(int) instance.value(splitAttr)].distributionForInstance(instance); } }
From source file:dewaweebtreeclassifier.Veranda.java
/** * /*w w w .ja v a 2s . c o m*/ * @param instance * @return * @throws java.lang.Exception */ @Override public double classifyInstance(Instance instance) throws Exception { if (instance.hasMissingValue()) throw new Exception("The instance has missing value(s). ID3 does not support missing values."); return mRoot.classifyInstance(instance); }
From source file:dewaweebtreeclassifier.Veranda.java
/** * // w w w . j a v a 2 s . c o m * @param data * @return */ public boolean isHaveMissingAttributes(Instances data) { Enumeration enumInst = data.enumerateInstances(); while (enumInst.hasMoreElements()) { Instance instance = (Instance) enumInst.nextElement(); if (instance.hasMissingValue()) { return true; } } return false; }
From source file:id3.MyID3.java
/** * Mengklasifikasikan instance/*w w w .j a v a2 s.co m*/ * @param instance data yang ingin di klasifikasikan * @return hasil klasifikasi * @throws NoSupportForMissingValuesException */ public double classifyInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Cannot handle missing value"); } if (currentAttribute == null) { return classLabel; } else { return subTree[(int) instance.value(currentAttribute)].classifyInstance(instance); } }
From source file:id3.MyID3.java
/** * Menghitung pendistribusian class dalam instances * @param instance data yang ingin dihitung distribusinya * @return distribusi kelas dari instance * @throws NoSupportForMissingValuesException *//*from w w w . ja va 2 s . c om*/ public double[] distributionForInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Cannot handle missing value"); } if (currentAttribute == null) { return classDistributionAmongInstances; } else { return subTree[(int) instance.value(currentAttribute)].distributionForInstance(instance); } }
From source file:myID3.MyId3.java
/** * Classifies a given test instance using the decision tree. * * @param instance the instance to be classified * @return the classification/*from w w w.j a va 2s . c o m*/ * @throws NoSupportForMissingValuesException if instance has missing values */ public double classifyInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Id3: no missing values, " + "please."); } if (currentAttribute == null) { return classValue; } else { return nodes[(int) instance.value(currentAttribute)].classifyInstance(instance); } }
From source file:myID3.MyId3.java
/** * Computes class distribution for instance using decision tree. * * @param instance the instance for which distribution is to be computed * @return the class distribution for the given instance * @throws NoSupportForMissingValuesException if instance has missing values *//*from w w w . j a va2 s . c o m*/ public double[] distributionForInstance(Instance instance) throws NoSupportForMissingValuesException { if (instance.hasMissingValue()) { throw new NoSupportForMissingValuesException("Id3: no missing values, " + "please."); } if (currentAttribute == null) { return classDistribution; } else { return nodes[(int) instance.value(currentAttribute)].distributionForInstance(instance); } }