com.spotify.zoltar.PredictorBuilder Maven / Gradle / Ivy
/*-
* -\-\-
* zoltar-core
* --
* Copyright (C) 2016 - 2018 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/
package com.spotify.zoltar;
import com.spotify.zoltar.PredictFns.AsyncPredictFn;
import java.util.function.Function;
/**
* PredictorBuilder holds the necessary info to build a {@link Predictor}.
*
* @param underlying type of the {@link Model}.
* @param type of the input to the {@link FeatureExtractor}.
* @param type of the output from {@link FeatureExtractor}.
* @param type of the prediction result.
*/
public interface PredictorBuilder, InputT, VectorT, ValueT> {
ModelLoader modelLoader();
FeatureExtractor featureExtractor();
AsyncPredictFn predictFn();
Predictor predictor();
PredictorBuilder with(
ModelLoader modelLoader,
FeatureExtractor featureExtractor,
AsyncPredictFn predictFn);
@SuppressWarnings("unchecked")
default > C with(
final ModelLoader modelLoader) {
return (C) with(modelLoader, featureExtractor(), predictFn());
}
@SuppressWarnings("unchecked")
default > C with(
final FeatureExtractor featureExtractor) {
return (C) with(modelLoader(), featureExtractor, predictFn());
}
@SuppressWarnings("unchecked")
default > C with(
final AsyncPredictFn predictFn) {
return (C) with(modelLoader(), featureExtractor(), predictFn);
}
default > C with(
final Function, C> fn) {
return fn.apply(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy