Package hivemall.io

Examples of hivemall.io.PredictionResult


    @Test
    public void testEta() {
        PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF();
        float loss = 0.1f;

        PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
        float expectedLearningRate1 = 2.0f;
        assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);

        PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
        float expectedLearningRate2 = 10.0f;
        assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
    }
View Full Code Here


        /* do initialize() with aggressiveness parameter */
        udtf.initialize(new ObjectInspector[]{intListOI, intOI, param});
        float loss = 0.1f;

        PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
        float expectedLearningRate1 = 2.0f;
        assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);

        PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
        float expectedLearningRate2 = 3.0f;
        assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
    }
View Full Code Here

        ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);

        udtf.initialize(new ObjectInspector[]{intListOI, intOI});
        float loss = 0.1f;

        PredictionResult margin = new PredictionResult(0.5f).squaredNorm(0.05f);
        float expectedLearningRate = 1.0f;
        assertEquals(expectedLearningRate, udtf.eta(loss, margin), 1e-5f);
    }
View Full Code Here

        /* do initialize() with aggressiveness parameter */
        udtf.initialize(new ObjectInspector[]{intListOI, intOI});
        float loss = 0.1f;

        PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
        float expectedLearningRate1 = 0.1818181f;
        assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);

        PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
        float expectedLearningRate2 = 0.1960784f;
        assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
    }
View Full Code Here

        /* do initialize() with aggressiveness parameter */
        udtf.initialize(new ObjectInspector[]{intListOI, intOI, param});
        float loss = 0.1f;

        PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
        float expectedLearningRate1 = 0.4615384f;
        assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);

        PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
        float expectedLearningRate2 = 0.5660377f;
        assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
    }
View Full Code Here

            if(old_w != 0f) {
                score += (old_w * v);
            }
            squared_norm += (v * v);
        }
        return new PredictionResult(score).squaredNorm(squared_norm);
    }
View Full Code Here

                score += (old_w.get() * v);
                variance += (old_w.getCovariance() * v * v);
            }
        }

        return new PredictionResult(score).variance(variance);
    }
View Full Code Here

        return cl;
    }

    @Override
    protected void train(Collection<?> features, float target) {
        PredictionResult margin = calcScoreAndVariance(features);
        float predicted = margin.getScore();

        float loss = loss(target, predicted);

        float var = margin.getVariance();
        float beta = 1.f / (var + r);

        update(features, loss, beta);
    }
View Full Code Here

    @Override
    protected void train(final List<?> features, final Object actual_label) {
        assert (actual_label != null);

        PredictionResult predicted = classify(features);
        Object predicted_label = predicted.getLabel();

        if(!actual_label.equals(predicted_label)) {
            update(features, 1.f, actual_label, predicted_label);
        }
    }
View Full Code Here

        @Override
        protected void train(Collection<?> features, float target) {
            preTrain(target);

            PredictionResult margin = calcScoreAndVariance(features);
            float predicted = margin.getScore();

            float loss = loss(target, predicted);
            if(loss > 0.f) {
                float coeff = (target - predicted) > 0.f ? loss : -loss;
                float var = margin.getVariance();
                float beta = 1.f / (var + r);
                update(features, coeff, beta);
            }
        }
View Full Code Here

TOP

Related Classes of hivemall.io.PredictionResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.