Search in sources :

Example 11 with ModelMetricsBinomial

use of hex.ModelMetricsBinomial in project h2o-3 by h2oai.

the class DeepWaterAbstractIntegrationTest method Airlines.

@Test
public void Airlines() {
    Frame tr = null;
    DeepWaterModel m = null;
    Frame[] splits = null;
    try {
        DeepWaterParameters p = new DeepWaterParameters();
        File file = FileUtils.locateFile("smalldata/airlines/allyears2k_headers.zip");
        if (file != null) {
            p._response_column = "IsDepDelayed";
            p._ignored_columns = new String[] { "DepTime", "ArrTime", "Cancelled", "CancellationCode", "Diverted", "CarrierDelay", "WeatherDelay", "NASDelay", "SecurityDelay", "LateAircraftDelay", "IsArrDelayed" };
            NFSFileVec trainfv = NFSFileVec.make(file);
            tr = ParseDataset.parse(Key.make(), trainfv._key);
            for (String col : new String[] { p._response_column, "UniqueCarrier", "Origin", "Dest" }) {
                Vec v = tr.remove(col);
                tr.add(col, v.toCategoricalVec());
                v.remove();
            }
            DKV.put(tr);
            double[] ratios = ard(0.5, 0.5);
            Key[] keys = aro(Key.make("test.hex"), Key.make("train.hex"));
            splits = ShuffleSplitFrame.shuffleSplitFrame(tr, keys, ratios, 42);
            p._backend = getBackend();
            p._train = keys[0];
            p._valid = keys[1];
            DeepWater j = new DeepWater(p);
            m = j.trainModel().get();
            Assert.assertTrue(((ModelMetricsBinomial) (m._output._validation_metrics)).auc() > 0.65);
        }
    } finally {
        if (tr != null)
            tr.remove();
        if (m != null)
            m.remove();
        if (splits != null)
            for (Frame s : splits) s.remove();
    }
}
Also used : Frame(water.fvec.Frame) ShuffleSplitFrame(hex.splitframe.ShuffleSplitFrame) NFSFileVec(water.fvec.NFSFileVec) ModelMetricsBinomial(hex.ModelMetricsBinomial) NFSFileVec(water.fvec.NFSFileVec) Vec(water.fvec.Vec)

Example 12 with ModelMetricsBinomial

use of hex.ModelMetricsBinomial in project h2o-3 by h2oai.

the class DRFTest method testNoRowWeights.

@Test
public void testNoRowWeights() {
    Frame tfr = null, vfr = null;
    DRFModel drf = null;
    Scope.enter();
    try {
        tfr = parse_test_file("smalldata/junit/no_weights.csv");
        DKV.put(tfr);
        DRFModel.DRFParameters parms = new DRFModel.DRFParameters();
        parms._train = tfr._key;
        parms._response_column = "response";
        parms._seed = 234;
        parms._min_rows = 1;
        parms._max_depth = 2;
        parms._ntrees = 3;
        // Build a first model; all remaining models should be equal
        drf = new DRF(parms).trainModel().get();
        // OOB
        ModelMetricsBinomial mm = (ModelMetricsBinomial) drf._output._training_metrics;
        assertEquals(_AUC, mm.auc_obj()._auc, 1e-8);
        assertEquals(_MSE, mm.mse(), 1e-8);
        assertEquals(_LogLoss, mm.logloss(), 1e-6);
    } finally {
        if (tfr != null)
            tfr.remove();
        if (vfr != null)
            vfr.remove();
        if (drf != null)
            drf.remove();
        Scope.exit();
    }
}
Also used : Frame(water.fvec.Frame) SplitFrame(hex.SplitFrame) ModelMetricsBinomial(hex.ModelMetricsBinomial) Test(org.junit.Test)

Example 13 with ModelMetricsBinomial

use of hex.ModelMetricsBinomial in project h2o-3 by h2oai.

the class DRFTest method testMTrys.

@Test
public void testMTrys() {
    Frame tfr = null;
    Vec old = null;
    DRFModel drf1 = null;
    for (int i = 1; i <= 6; ++i) {
        Scope.enter();
        try {
            tfr = parse_test_file("smalldata/junit/cars_20mpg.csv");
            // Remove unique id
            tfr.remove("name").remove();
            tfr.remove("economy").remove();
            old = tfr.remove("economy_20mpg");
            // response to last column
            tfr.add("economy_20mpg", VecUtils.toCategoricalVec(old));
            DKV.put(tfr);
            DRFModel.DRFParameters parms = new DRFModel.DRFParameters();
            parms._train = tfr._key;
            parms._response_column = "economy_20mpg";
            parms._min_rows = 2;
            parms._ntrees = 5;
            parms._max_depth = 5;
            parms._nfolds = 3;
            parms._mtries = i;
            drf1 = new DRF(parms).trainModel().get();
            ModelMetricsBinomial mm1 = (ModelMetricsBinomial) drf1._output._cross_validation_metrics;
            Assert.assertTrue(mm1._auc != null);
        } finally {
            if (tfr != null)
                tfr.remove();
            if (old != null)
                old.remove();
            if (drf1 != null) {
                drf1.deleteCrossValidationModels();
                drf1.delete();
            }
            Scope.exit();
        }
    }
}
Also used : Frame(water.fvec.Frame) SplitFrame(hex.SplitFrame) Vec(water.fvec.Vec) ModelMetricsBinomial(hex.ModelMetricsBinomial) Test(org.junit.Test)

Aggregations

ModelMetricsBinomial (hex.ModelMetricsBinomial)13 Frame (water.fvec.Frame)13 Test (org.junit.Test)11 SplitFrame (hex.SplitFrame)10 Vec (water.fvec.Vec)4 NFSFileVec (water.fvec.NFSFileVec)3 ShuffleSplitFrame (hex.splitframe.ShuffleSplitFrame)2 DeepLearningParameters (hex.deeplearning.DeepLearningModel.DeepLearningParameters)1 Ignore (org.junit.Ignore)1 Key (water.Key)1