001package javax.visrec.ml.regression;
002
003import javax.visrec.util.ModelProvider;
004
005/**
006 * Simple linear regression finds the best possible straight line that tries to explain given training set.
007 * 
008 * @author zoran
009 */
010public abstract class SimpleLinearRegression<MODEL_CLASS> implements Regressor<Float, Float>, ModelProvider<MODEL_CLASS> {
011
012    private MODEL_CLASS model;
013    
014    public MODEL_CLASS getModel() {
015        return model;
016    }
017
018    protected void setModel(MODEL_CLASS model) {
019        this.model = model;
020    }
021    
022    @Override
023    public abstract Float predict(Float inputs);    
024    
025    /**
026     * How much on average output change when input changes by one. 
027     * If it is zero there is no linear dependency between input and output, and data is probably scattered.
028     * If it is less then one output grows slower then input.
029     * If it is greater than one, then output is growing faster than input.
030     * If its negative, then output is lowering as input grows.
031     * 
032     * @return
033     */
034    public abstract float getSlope();
035
036    /**
037     * The value of output when input is zero
038     * @return 
039     */
040    public abstract float getIntercept();
041    // ili da vracam parametre modela u mapi?
042    // ili kao niz koeficijenata?
043
044    // performance measures
045    // RSE
046    // R2    
047    
048
049//    Map.new().put()
050    
051}