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.common.libsvm;
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.Output;
023
024import java.io.Serializable;
025
026/**
027 * A carrier type for the SVM type. It really wants to be a set of enums with
028 * different type parameters, but it's encoded as an interface where each
029 * subclass for an {@link Output} implementation contains an enum with it's
030 * valid values.
031 * <p>
032 * LibSVM supported enum values are:
033 * <ul>
034 * <li>C_SVC(0) - Original SVM algorithm.</li>
035 * <li>NU_SVC(1) - Original SVM, optimization in dual space.</li>
036 * <li>ONE_CLASS(2) - Anomaly detection SVM.</li>
037 * <li>EPSILON_SVR(3) - epsilon-insensitive SVR.</li>
038 * <li>NU_SVR(4) - nu-SVR, optimization in dual space.</li>
039 * </ul>
040 */
041public interface SVMType<T extends Output<T>> extends Configurable, Provenancable<ConfiguredObjectProvenance>, Serializable {
042    /**
043     * Is this a classification algorithm.
044     * @return True if it's a classification algorithm.
045     */
046    public boolean isClassification();
047
048    /**
049     * Is this a regression algorithm.
050     * @return True if it's a regression algorithm.
051     */
052    public boolean isRegression();
053
054    /**
055     * Is this an anomaly detection algorithm.
056     * @return True if it's an anomaly detection algorithm.
057     */
058    public boolean isAnomaly();
059
060    /**
061     * Is this a nu-SVM.
062     * @return True if it's a nu-SVM.
063     */
064    public boolean isNu();
065
066    /**
067     * The LibSVM int id for the algorithm.
068     * @return The int id.
069     */
070    public int getNativeType();
071}