001/* 002 * Copyright (c) 2015-2021, 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.liblinear; 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; 023import de.bwaldvogel.liblinear.SolverType; 024 025import java.io.Serializable; 026 027/** 028 * A carrier type for the liblinear algorithm type. It really wants to be a set of enums with 029 * different type parameters, but it's encoded as an interface where each 030 * subclass for an {@link Output} implementation contains an enum with it's 031 * valid values. 032 * <p> 033 * LibLinear supported enum values for various tasks are: 034 * <ul> 035 * <li>L2R_LR - L2-regularized logistic regression (primal)</li> 036 * <li>L2R_L2LOSS_SVC_DUAL - L2-regularized L2-loss support vector classification (dual)</li> 037 * <li>L2R_L2LOSS_SVC - L2-regularized L2-loss support vector classification (primal)</li> 038 * <li>L2R_L1LOSS_SVC_DUAL - L2-regularized L1-loss support vector classification (dual)</li> 039 * <li>MCSVM_CS - multi-class support vector classification by Crammer and Singer</li> 040 * <li>L1R_L2LOSS_SVC - L1-regularized L2-loss support vector classification</li> 041 * <li>L1R_LR - L1-regularized logistic regression</li> 042 * <li>L2R_LR_DUAL - L2-regularized logistic regression (dual)</li> 043 * <li>L2R_L2LOSS_SVR - L2-regularized L2-loss support vector regression (primal)</li> 044 * <li>L2R_L2LOSS_SVR_DUAL - L2-regularized L2-loss support vector regression (dual)</li> 045 * <li>L2R_L1LOSS_SVR_DUAL - L2-regularized L1-loss support vector regression (dual)</li> 046 * </ul> 047 */ 048public interface LibLinearType<T extends Output<T>> extends Configurable, Provenancable<ConfiguredObjectProvenance>, Serializable { 049 /* 050 // L2-regularized logistic regression (primal) 051 L2R_LR, 052 // L2-regularized L2-loss support vector classification (dual) 053 L2R_L2LOSS_SVC_DUAL, 054 // L2-regularized L2-loss support vector classification (primal) 055 L2R_L2LOSS_SVC, 056 // L2-regularized L1-loss support vector classification (dual) 057 L2R_L1LOSS_SVC_DUAL, 058 // multi-class support vector classification by Crammer and Singer 059 MCSVM_CS, 060 // L1-regularized L2-loss support vector classification 061 L1R_L2LOSS_SVC, 062 // L1-regularized logistic regression 063 L1R_LR, 064 // L2-regularized logistic regression (dual) 065 L2R_LR_DUAL, 066 // L2-regularized L2-loss support vector regression (primal) 067 L2R_L2LOSS_SVR, 068 // L2-regularized L2-loss support vector regression (dual) 069 L2R_L2LOSS_SVR_DUAL, 070 // L2-regularized L1-loss support vector regression (dual) 071 L2R_L1LOSS_SVR_DUAL, 072 // One-class SVM 073 ONECLASS_SVM; 074 */ 075 076 /** 077 * Is this class a Classification algorithm? 078 * @return True if it's a classification algorithm. 079 */ 080 public boolean isClassification(); 081 082 /** 083 * Is this class a Regression algorithm? 084 * @return True if it's a regression algorithm. 085 */ 086 public boolean isRegression(); 087 088 /** 089 * Is this class an anomaly detection algorithm? 090 * @return True if it's an anomaly detection algorithm. 091 */ 092 public boolean isAnomaly(); 093 094 /** 095 * Returns the liblinear enum type. 096 * @return The liblinear enum type. 097 */ 098 public SolverType getSolverType(); 099}