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 com.oracle.labs.mlrg.olcut.provenance.Provenance; 020 021import java.util.Collections; 022import java.util.Map; 023 024/** 025 * Denotes this trainer emits a {@link SparseModel}. 026 */ 027public interface SparseTrainer<T extends Output<T>> extends Trainer<T> { 028 029 /** 030 * Trains a sparse predictive model using the examples in the given data set. 031 * @param examples The data set containing the examples. 032 * @return A sparse predictive model that can be used to generate predictions for new examples. 033 */ 034 @Override 035 default public SparseModel<T> train(Dataset<T> examples) { 036 return train(examples, Collections.emptyMap()); 037 } 038 039 /** 040 * Trains a sparse predictive model using the examples in the given data set. 041 * @param examples the data set containing the examples. 042 * @param runProvenance Training run specific provenance (e.g., fold number). 043 * @return a predictive model that can be used to generate predictions for new examples. 044 */ 045 @Override 046 public SparseModel<T> train(Dataset<T> examples, Map<String, Provenance> runProvenance); 047 048}