/** * Returns a single scalar probability in the case where we have two categories. Using this * method avoids an extra vector allocation as opposed to calling classify() or an extra two * vector allocations relative to classifyFull(). * * @param instance The vector of features to be classified. * @return The probability of the first of two categories. * @throws IllegalArgumentException If the classifier doesn't have two categories. */ @Override public double classifyScalar(Vector instance) { Preconditions.checkArgument(numCategories() == 2, "Can only call classifyScalar with two categories"); // apply pending regularization to whichever coefficients matter regularize(instance); // result is a vector with one element so we can just use dot product return link(classifyScalarNoLink(instance)); }
/** * Returns a single scalar probability in the case where we have two categories. Using this * method avoids an extra vector allocation as opposed to calling classify() or an extra two * vector allocations relative to classifyFull(). * * @param instance The vector of features to be classified. * @return The probability of the first of two categories. * @throws IllegalArgumentException If the classifier doesn't have two categories. */ @Override public double classifyScalar(Vector instance) { Preconditions.checkArgument(numCategories() == 2, "Can only call classifyScalar with two categories"); // apply pending regularization to whichever coefficients matter regularize(instance); // result is a vector with one element so we can just use dot product return link(classifyScalarNoLink(instance)); }
/** * Returns a single scalar probability in the case where we have two categories. Using this * method avoids an extra vector allocation as opposed to calling classify() or an extra two * vector allocations relative to classifyFull(). * * @param instance The vector of features to be classified. * @return The probability of the first of two categories. * @throws IllegalArgumentException If the classifier doesn't have two categories. */ @Override public double classifyScalar(Vector instance) { Preconditions.checkArgument(numCategories() == 2, "Can only call classifyScalar with two categories"); // apply pending regularization to whichever coefficients matter regularize(instance); // result is a vector with one element so we can just use dot product return link(classifyScalarNoLink(instance)); }