/** * Returns the distribution for the given instance. * * @param instance the test instance * @return the distribution array * @throws Exception if distribution can't be computed successfully */ @Override public double[] distributionForInstance(Instance instance) throws Exception { return m_Classifier.distributionForInstance(instance); }
/** * Returns the distribution for the given instance. * * @param instance the test instance * @return the distribution array * @throws Exception if distribution can't be computed successfully */ @Override public double[] distributionForInstance(Instance instance) throws Exception { return m_Classifier.distributionForInstance(instance); }
/** * Calculates the class membership probabilities for the given test * instance. * * @param instance the instance to be classified * @return preedicted class probability distribution * @throws Exception if distribution can't be computed successfully */ public double[] distributionForInstance(Instance instance) throws Exception { return m_Classifier.distributionForInstance(instance); }
/** * Returns class probabilities. * * @param instance the instance to be classified * @return the distribution for the instance * @throws Exception if instance could not be classified * successfully */ public double[] distributionForInstance(Instance instance) throws Exception { return m_Classifier.distributionForInstance(instance); }
@Override public Map<Object, Double> classDistribution(Instance instance) { try { Map<Object, Double> out = new HashMap<Object, Double>(); double[] distr = wekaClass.distributionForInstance(utils.instanceToWeka(instance)); for (int i = 0; i < distr.length; i++) out.put(utils.convertClass(i), distr[i]); return out; } catch (Exception e) { throw new WekaException(e); } }
/** * The distribution this this node, given input x. * @return p( y_j = k | x , y_pred ) for k in {0,1} */ public double[] distribution(Instance x, double ypred[]) throws Exception { Instance x_ = transform(x,ypred); return h.distributionForInstance(x_); }
/** * Store the prediction made by the classifier as a string. * * @param classifier the classifier to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ protected void doPrintClassification(Classifier classifier, Instance inst, int index) throws Exception { double[] d = classifier.distributionForInstance(inst); doPrintClassification(d, inst, index); }
/** * Store the prediction made by the classifier as a string. * * @param classifier the classifier to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ protected void doPrintClassification(Classifier classifier, Instance inst, int index) throws Exception { double[] d = classifier.distributionForInstance(inst); doPrintClassification(d, inst, index); }
/** * Returns estimated class probabilities for the given instance if the class is nominal and a * one-element array containing the numeric prediction if the class is numeric. * * @param instance the instance to be classified * @return the distribution * @throws Exception if instance could not be classified successfully */ public double[] distributionForInstance(Instance instance) throws Exception { return m_MetaClassifier.distributionForInstance(metaInstance(instance)); }
/** * Store the prediction made by the classifier as a string. * * @param classifier the classifier to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ protected void doPrintClassification(Classifier classifier, Instance inst, int index) throws Exception { double[] d = classifier.distributionForInstance(inst); doPrintClassification(d, inst, index); }
/** * Store the prediction made by the classifier as a string. * * @param classifier the classifier to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ protected void doPrintClassification(Classifier classifier, Instance inst, int index) throws Exception { double[] d = classifier.distributionForInstance(inst); doPrintClassification(d, inst, index); }
@Override public double[] distributionForInstance(Instance inst) throws Exception { Instance converted = constructMappedInstance(inst); return m_Classifier.distributionForInstance(converted); }
/** * Return the argmax on #distribution(Instance, double[]). * @return argmax_{k in 0,1,...} p( y_j = k | x , y_pred ) */ public double classify(Instance x, double ypred[]) throws Exception { Instance x_ = transform(x,ypred); return Utils.maxIndex(h.distributionForInstance(x_)); }
@Override public double[] distributionForInstance(Instance x) throws Exception { Instance x_transformed = this.transformInstance(x); double[] y_transformed = m_Classifier.distributionForInstance(x_transformed); double[] y = this.transformPredictionsBack(y_transformed); return y; }
@Override public double[] distributionForInstance(Instance x) throws Exception { int L = x.classIndex(); // if there is only one class (as for e.g. in some hier. mtds) predict it if(L == 1) return new double[]{1.0}; Instance x_ = PSUtils.convertInstance(x,L,m_InstancesTemplate); //convertInstance(x,L); //x_.setDataset(m_InstancesTemplate); // Get a classification return PSUtils.recombination_t(m_Classifier.distributionForInstance(x_),L,m_InstancesTemplate); }
@Override public double[] distributionForInstance(Instance x) throws Exception { int L = x.classIndex(); // if there is only one class (as for e.g. in some hier. mtds) predict it if(L == 1) return new double[]{1.0}; Instance x_ = PSUtils.convertInstance(x,L,m_InstancesTemplate); //convertInstance(x,L); //x_.setDataset(m_InstancesTemplate); // Get a classification return PSUtils.recombination_t(m_Classifier.distributionForInstance(x_),L,m_InstancesTemplate); }
@Override public double[] distributionForInstance(Instance TestInstance) throws Exception { int c = TestInstance.classIndex(); //if there is only one class (as for e.g. in some hier. mtds) predict it if(c == 1) return new double[]{1.0}; Instance mlInstance = convertInstance(TestInstance,c); mlInstance.setDataset(m_InstancesTemplate); //Get a classification return convertDistribution(m_Classifier.distributionForInstance(mlInstance),c); }
@Override public double[] distributionForInstance(Instance inst) throws Exception { if (!getPreConstructedFilter().input(inst)) { throw new Exception("Filter did not make instance available immediately!"); } getPreConstructedFilter().batchFinished(); Instance testI = getPreConstructedFilter().output(); return getClassifier().distributionForInstance(testI); }
protected MultiLabelOutput makePredictionInternal(Instance instance) throws Exception { //delete labels instance = RemoveAllLabels.transformInstance(instance, labelIndices); instance.setDataset(null); instance.insertAttributeAt(instance.numAttributes()); instance.setDataset(header); double[] distribution = baseClassifier.distributionForInstance(instance); MultiLabelOutput mlo = new MultiLabelOutput(MultiLabelOutput.ranksFromValues(distribution)); return mlo; } }
@Override public double[] distributionForInstance(Instance xy) throws Exception { int L = xy.classIndex(); double z[] = dbm.prob_z(MLUtils.getxfromInstance(xy)); Instance zy = (Instance)m_InstancesTemplate.firstInstance().copy(); MLUtils.setValues(zy,z,L); zy.setDataset(m_InstancesTemplate); return m_Classifier.distributionForInstance(zy); }