/** * Convenience method to create a new, empty * {@code DefaultWeightedInputOutputPair}. * * @param <InputType> * The type for the input object in the pair. * @param <OutputType> * The type for the output object in the pair. * @return * A new, empty {@code DefaultWeightedInputOutputPair}. */ public static <InputType, OutputType> DefaultWeightedInputOutputPair<InputType, OutputType> create() { return new DefaultWeightedInputOutputPair<InputType, OutputType>(); }
result.add(create(ii.next(), io.next(), iw.next().doubleValue()));
/** * Updates the weightedData from the given prediction function and * the internal Kernel * @param f * Prediction function to use to update the weights of the weightedData * using the Kernel * @return Mean L1 norm of the weight change */ private double updateWeights( Evaluator<? super InputType, ? extends OutputType> f ) { double change = 0.0; for (DefaultWeightedInputOutputPair<InputType, OutputType> pair : this.weightedData) { // Use the kernel to determine the new weight of the sample // Generally, the kernel should weight accurate samples more // than inaccurate samples OutputType yhat = f.evaluate( pair.getInput() ); double weightNew = this.kernelWeightingFunction.evaluate( pair.getOutput(), yhat ); double weightOld = pair.getWeight(); change += Math.abs( weightNew - weightOld ); pair.setWeight( weightNew ); } change /= this.weightedData.size(); return change; }
new DefaultWeightedInputOutputPair<InputType, Boolean>( example, 1.0)); numExamples++; : this.weightedData) example.setWeight(initialWeight);
/** * Creates a new {@code DefaultWeightedInputOutputPair} with the given * input, output, and weight. * * @param input * The input. * @param output * The output. * @param weight * The weight. */ public DefaultWeightedInputOutputPair( final InputType input, final OutputType output, final double weight) { super(input, output); this.setWeight(weight); }
new DefaultWeightedInputOutputPair<InputType, Boolean>( example, 1.0)); numExamples++; : this.weightedData) example.setWeight(initialWeight);
/** * Creates a new {@code DefaultWeightedInputOutputPair} with the given * input, output, and weight. * * @param input * The input. * @param output * The output. * @param weight * The weight. */ public DefaultWeightedInputOutputPair( final InputType input, final OutputType output, final double weight) { super(input, output); this.setWeight(weight); }
/** * Updates the weightedData from the given prediction function and * the internal Kernel * @param f * Prediction function to use to update the weights of the weightedData * using the Kernel * @return Mean L1 norm of the weight change */ private double updateWeights( Evaluator<? super InputType, ? extends OutputType> f ) { double change = 0.0; for (DefaultWeightedInputOutputPair<InputType, OutputType> pair : this.weightedData) { // Use the kernel to determine the new weight of the sample // Generally, the kernel should weight accurate samples more // than inaccurate samples OutputType yhat = f.evaluate( pair.getInput() ); double weightNew = this.kernelWeightingFunction.evaluate( pair.getOutput(), yhat ); double weightOld = pair.getWeight(); change += Math.abs( weightNew - weightOld ); pair.setWeight( weightNew ); } change /= this.weightedData.size(); return change; }
/** * Convenience method to create a new, empty * {@code DefaultWeightedInputOutputPair}. * * @param <InputType> * The type for the input object in the pair. * @param <OutputType> * The type for the output object in the pair. * @return * A new, empty {@code DefaultWeightedInputOutputPair}. */ public static <InputType, OutputType> DefaultWeightedInputOutputPair<InputType, OutputType> create() { return new DefaultWeightedInputOutputPair<InputType, OutputType>(); }
new DefaultWeightedInputOutputPair<InputType, Boolean>( example, 1.0)); numExamples++; : this.weightedData) example.setWeight(initialWeight);
result.add(create(ii.next(), io.next(), iw.next().doubleValue()));
/** * Creates a new {@code DefaultWeightedInputOutputPair} with the given * input, output, and weight. * * @param input * The input. * @param output * The output. * @param weight * The weight. */ public DefaultWeightedInputOutputPair( final InputType input, final OutputType output, final double weight) { super(input, output); this.setWeight(weight); }
/** * Updates the weightedData from the given prediction function and * the internal Kernel * @param f * Prediction function to use to update the weights of the weightedData * using the Kernel * @return Mean L1 norm of the weight change */ private double updateWeights( Evaluator<? super InputType, ? extends OutputType> f ) { double change = 0.0; for (DefaultWeightedInputOutputPair<InputType, OutputType> pair : this.weightedData) { // Use the kernel to determine the new weight of the sample // Generally, the kernel should weight accurate samples more // than inaccurate samples OutputType yhat = f.evaluate( pair.getInput() ); double weightNew = this.kernelWeightingFunction.evaluate( pair.getOutput(), yhat ); double weightOld = pair.getWeight(); change += Math.abs( weightNew - weightOld ); pair.setWeight( weightNew ); } change /= this.weightedData.size(); return change; }
/** * Convenience method to create a new, empty * {@code DefaultWeightedInputOutputPair}. * * @param <InputType> * The type for the input object in the pair. * @param <OutputType> * The type for the output object in the pair. * @return * A new, empty {@code DefaultWeightedInputOutputPair}. */ public static <InputType, OutputType> DefaultWeightedInputOutputPair<InputType, OutputType> create() { return new DefaultWeightedInputOutputPair<InputType, OutputType>(); }
result.add(create(ii.next(), io.next(), iw.next().doubleValue()));
double localWeight = kernelWeight * originalWeight; locallyWeightedPair.setWeight( localWeight );
for (DefaultWeightedInputOutputPair<?, ?> example : this.weightedData) weightSum += example.getWeight(); example.setWeight(example.getWeight() / weightSum); final CategoryType actual = example.getOutput(); final CategoryType predicted = member.evaluate(example.getInput()); final boolean correct = ObjectUtil.equalsSafe(predicted, actual); weightedErrorRate += example.getWeight(); final double oldWeight = example.getWeight(); double newWeight = oldWeight * Math.pow(beta, 1.0 - (correct ? 0.0 : 1.0)); example.setWeight(newWeight);