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;
018
019import java.io.Serializable;
020
021/**
022 * Output is the root interface for the supported prediction types.
023 * <p>
024 * It's subclassed in each of the modules:
025 * <ul>
026 * <li>Label for multi-class classification</li>
027 * <li>MultiLabel for multi-label classification</li>
028 * <li>ClusterID for clustering</li>
029 * <li>Regressor for regression</li>
030 * <li>Event for anomaly detection</li>
031 * </ul>
032 * Equals and hashcode are defined to only look at the strings stored in an Output, not any score
033 * values. For equality that takes into account the scores, use {@link Output#fullEquals}.
034 */
035public interface Output<T extends Output<T>> extends Serializable {
036
037    /**
038     * Deep copy of the output up to it's immutable state.
039     * @return A copy of the output.
040     */
041    public T copy();
042
043    /**
044     * Generates a String suitable for writing to a csv or json file.
045     * @param includeConfidence Include whatever confidence score the label contains, if known.
046     * @return A String representation of this Output.
047     */
048    public String getSerializableForm(boolean includeConfidence);
049
050    /**
051     * Compares other to this output. Uses all score values
052     * and the strings.
053     * @param other Another output instance.
054     * @return True if the other instance has value equality to this instance. False otherwise.
055     */
056    public boolean fullEquals(T other);
057}