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

org.ranksys.javafm.BoundedFM Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2016 RankSys http://ranksys.org
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.ranksys.javafm;

import java.util.Random;
import static java.lang.Math.max;
import static java.lang.Math.min;

/**
 *
 * @author Saúl Vargas ([email protected])
 */
public class BoundedFM extends FM {

    private final double min;
    private final double max;

    public BoundedFM(double b, double[] w, double[][] m, double min, double max) {
        super(b, w, m);
        this.min = min;
        this.max = max;
    }

    public BoundedFM(double min, double max, int numFeatures, int K, Random rnd, double sdev) {
        super(numFeatures, K, rnd, sdev);
        this.min = min;
        this.max = max;
    }

    @Override
    public double predict(FMInstance x) {
        return min(max, max(min, super.predict(x)));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy