All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feedzai.openml.example.ExampleModelTrainer Maven / Gradle / Ivy

Go to download

Contains an example of a provider of Machine Learning Models implementing Feedzai's OpenML API. These examples are not true models (in the essence that they do not learn and simply return dummy predictions).

There is a newer version: 1.2.0
Show newest version
/*
 * Copyright 2018 Feedzai
 *
 * 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.feedzai.openml.example;

import com.feedzai.openml.data.Dataset;
import com.feedzai.openml.data.schema.DatasetSchema;
import com.feedzai.openml.provider.descriptor.fieldtype.ParamValidationError;
import com.feedzai.openml.provider.model.MachineLearningModelTrainer;
import com.google.common.collect.ImmutableList;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * An example model trainer.
 *
 * @author Pedro Rijo ([email protected])
 * @since 0.1.0
 */
public class ExampleModelTrainer extends ExampleModelLoader implements MachineLearningModelTrainer {

    /**
     * Model trainer.
     *
     * @param indexToPredict This loader always loads models that predict the field, indicated by this index, to be the
     *                       class of the instances.
     */
    public ExampleModelTrainer(final int indexToPredict) {
        super(indexToPredict);
    }

    @Override
    public ExampleModel fit(final Dataset dataset,
                            final Random random,
                            final Map params) {


        return loadModel(null, dataset.getSchema());
    }

    @Override
    public List validateForFit(final Path pathToPersist,
                                                     final DatasetSchema schema,
                                                     final Map params) {
        return ImmutableList.of();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy