001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo.ensemble;
018
019import com.oracle.labs.mlrg.olcut.config.Configurable;
020import com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance;
021import com.oracle.labs.mlrg.olcut.provenance.Provenancable;
022import org.tribuo.ImmutableOutputInfo;
023import org.tribuo.Output;
024import org.tribuo.Prediction;
025
026import java.io.Serializable;
027import java.util.List;
028
029/**
030 * An interface for combining predictions. Implementations should be final and immutable.
031 */
032public interface EnsembleCombiner<T extends Output<T>> extends Configurable, Provenancable<ConfiguredObjectProvenance>, Serializable {
033
034    /**
035     * Combine the predictions.
036     * @param outputInfo The output domain.
037     * @param predictions The predictions to combine.
038     * @return The ensemble prediction.
039     */
040    public Prediction<T> combine(ImmutableOutputInfo<T> outputInfo, List<Prediction<T>> predictions);
041
042    /**
043     * Combine the supplied predictions. predictions.size() must equal weights.length.
044     * @param outputInfo The output domain.
045     * @param predictions The predictions to combine.
046     * @param weights The weights to use for each prediction.
047     * @return The ensemble prediction.
048     */
049    public Prediction<T> combine(ImmutableOutputInfo<T> outputInfo, List<Prediction<T>> predictions, float[] weights);
050
051}