List of usage examples for weka.core UnassignedClassException UnassignedClassException
public UnassignedClassException(String message)
From source file:adams.opt.cso.Measure.java
License:Open Source License
/** * Checks whether the data can be used with this measure. * * @param data the data to check//from w w w.j a v a 2 s .co m * @return true if the measure can be obtain for this kind of data */ public boolean isValid(Instances data) { if (data.classIndex() == -1) throw new UnassignedClassException("No class attribute set!"); if (data.classAttribute().isNominal()) return m_Nominal; else if (data.classAttribute().isNumeric()) return m_Numeric; else throw new IllegalStateException("Class attribute '" + data.classAttribute().type() + "' not handled!"); }
From source file:com.jgaap.util.Instance.java
License:Open Source License
/** * Tests if an instance's class is missing. * * @return true if the instance's class is missing * @throws UnassignedClassException if the class is not set or the instance doesn't * have access to a dataset// w w w. jav a 2s . c o m */ //@ requires classIndex() >= 0; public /*@pure@*/ boolean classIsMissing() { if (classIndex() < 0) { throw new UnassignedClassException("Class is not set!"); } return isMissing(classIndex()); }
From source file:com.jgaap.util.Instance.java
License:Open Source License
/** * Returns an instance's class value in internal format. (ie. as a * floating-point number)/*from www . j a v a 2s. c o m*/ * * @return the corresponding value as a double (If the * corresponding attribute is nominal (or a string) then it returns the * value's index as a double). * @throws UnassignedClassException if the class is not set or the instance doesn't * have access to a dataset */ //@ requires classIndex() >= 0; public /*@pure@*/ double classValue() { if (classIndex() < 0) { throw new UnassignedClassException("Class is not set!"); } return value(classIndex()); }
From source file:com.jgaap.util.Instance.java
License:Open Source License
/** * Sets the class value of an instance to be "missing". A deep copy of * the vector of attribute values is performed before the * value is set to be missing.//from w ww.ja v a 2 s .c om * * @throws UnassignedClassException if the class is not set * @throws UnassignedDatasetException if the instance doesn't * have access to a dataset */ //@ requires classIndex() >= 0; public void setClassMissing() { if (classIndex() < 0) { throw new UnassignedClassException("Class is not set!"); } setMissing(classIndex()); }
From source file:com.jgaap.util.Instance.java
License:Open Source License
/** * Sets the class value of an instance to the given value (internal * floating-point format). A deep copy of the vector of attribute * values is performed before the value is set. * * @param value the new attribute value (If the corresponding * attribute is nominal (or a string) then this is the new value's * index as a double). //from www . j a va 2 s. co m * @throws UnassignedClassException if the class is not set * @throws UnaddignedDatasetException if the instance doesn't * have access to a dataset */ //@ requires classIndex() >= 0; public void setClassValue(double value) { if (classIndex() < 0) { throw new UnassignedClassException("Class is not set!"); } setValue(classIndex(), value); }
From source file:de.uni_potsdam.hpi.bpt.promnicat.analysisModules.clustering.ProcessInstances.java
License:Open Source License
/** * Stratifies a set of instances according to its class values if the class * attribute is nominal (so that afterwards a stratified cross-validation * can be performed)./* ww w .ja va 2s . c om*/ * * @param numFolds * the number of folds in the cross-validation * @throws UnassignedClassException * if the class is not set */ public void stratify(int numFolds) { if (numFolds <= 1) { throw new IllegalArgumentException("Number of folds must be greater than 1"); } if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } if (classAttribute().isNominal()) { // sort by class int index = 1; while (index < numInstances()) { ProcessInstance instance1 = getInstance(index - 1); for (int j = index; j < numInstances(); j++) { ProcessInstance instance2 = getInstance(j); if ((instance1.classValue() == instance2.classValue()) || (instance1.classIsMissing() && instance2.classIsMissing())) { swap(index, j); index++; } } index++; } stratStep(numFolds); } }
From source file:milk.core.Exemplar.java
License:Open Source License
/** * Returns the class attribute./*from w w w . j av a2 s. c o m*/ * * @return the class attribute * @exception UnassignedClassException if the class is not set */ public final Attribute classAttribute() { if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } return m_Instances.attribute(m_ClassIndex); }
From source file:milk.core.Exemplar.java
License:Open Source License
/** * Returns the class value of this exemplar. * * @return the class value/*from ww w . j av a 2 s.co m*/ * @exception UnassignedClassException if the class is not set */ public final double classValue() { if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } return m_ClassValue; }
From source file:milk.core.Exemplars.java
License:Open Source License
/** * Returns the class attribute.//from ww w . j a v a2 s. co m * * @return the class attribute * @exception UnassignedClassException if the class is not set */ public final Attribute classAttribute() { if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } return attribute(m_ClassIndex); }
From source file:milk.core.Exemplars.java
License:Open Source License
/** * Returns the number of class labels.//www .j a v a2s. c om * * @return the number of class labels as an integer if the class * attribute is nominal, 1 otherwise. * @exception UnassignedClassException if the class is not set */ public final int numClasses() { if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } if (!classAttribute().isNominal()) { return 1; } else { return classAttribute().numValues(); } }