Search in sources :

Example 31 with Key

use of water.Key in project h2o-3 by h2oai.

the class ParserTestARFF method testReal.

@Test
public void testReal() {
    String data = "@RELATION type\n" + "\n" + "@ATTRIBUTE num ReAl\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
    double[][] exp = new double[][] { ard(0), ard(1.324e-13), ard(-2) };
    Key k = ParserTest.makeByteVec(data);
    ParserTest.testParsed(ParseDataset.parse(Key.make(), k), exp, 3);
}
Also used : Key(water.Key) Test(org.junit.Test)

Example 32 with Key

use of water.Key in project h2o-3 by h2oai.

the class ParserTestARFF method testStringSplit.

@Test
public void testStringSplit() {
    String data1 = "@RELATION type\n" + "\n" + "@ATTRIBUTE num STRING\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
    String data2 = "4\n" + "5234234234\n" + "6\n";
    Key k1 = ParserTest.makeByteVec(data1);
    Key k2 = ParserTest.makeByteVec(data2);
    Key[] k = new Key[] { k1, k2 };
    Frame fr = ParseDataset.parse(Key.make(), k);
    Assert.assertTrue(fr.anyVec().isString());
    Assert.assertFalse(fr.anyVec().isCategorical());
    Assert.assertFalse(fr.anyVec().isInt());
    BufferedString tmpStr = new BufferedString();
    Assert.assertTrue(fr.anyVec().atStr(tmpStr, 3).toString().equals("4"));
    Assert.assertTrue(fr.anyVec().atStr(tmpStr, 4).toString().equals("5234234234"));
    Assert.assertTrue(fr.anyVec().atStr(tmpStr, 5).toString().equals("6"));
    fr.delete();
}
Also used : Frame(water.fvec.Frame) Key(water.Key) Test(org.junit.Test)

Example 33 with Key

use of water.Key in project h2o-3 by h2oai.

the class ParserTestARFF method testMultipleFilesNum.

@Test
public void testMultipleFilesNum() {
    String data1 = "@RELATION type\n" + "\n" + "@ATTRIBUTE num numeric\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
    Key k1 = ParserTest.makeByteVec(data1);
    Key k2 = ParserTest.makeByteVec(data1);
    Key[] k = new Key[] { k1, k2 };
    Frame fr = ParseDataset.parse(Key.make(), k);
    Assert.assertFalse(fr.anyVec().isString());
    Assert.assertFalse(fr.anyVec().isCategorical());
    Assert.assertFalse(fr.anyVec().isInt());
    Assert.assertFalse(fr.anyVec().isUUID());
    Assert.assertTrue(fr.anyVec().at(0) == 0);
    Assert.assertTrue(fr.anyVec().at(1) == 1.324e-13);
    Assert.assertTrue(fr.anyVec().at(2) == -2);
    Assert.assertTrue(fr.anyVec().at(3) == 0);
    Assert.assertTrue(fr.anyVec().at(4) == 1.324e-13);
    Assert.assertTrue(fr.anyVec().at(5) == -2);
    fr.delete();
}
Also used : Frame(water.fvec.Frame) Key(water.Key) Test(org.junit.Test)

Example 34 with Key

use of water.Key in project h2o-3 by h2oai.

the class ParserTestARFF method testInt.

@Test
public void testInt() {
    String data = "@RELATION type\n" + "\n" + "@ATTRIBUTE num INT\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
    double[][] exp = new double[][] { ard(0), ard(1.324e-13), ard(-2) };
    Key k = ParserTest.makeByteVec(data);
    ParserTest.testParsed(ParseDataset.parse(Key.make(), k), exp, 3);
}
Also used : Key(water.Key) Test(org.junit.Test)

Example 35 with Key

use of water.Key in project h2o-3 by h2oai.

the class VecDataInputStreamTest method makeRandomByteVec.

private static Vec makeRandomByteVec(Vec blueprint) {
    final Vec v0 = new Vec(blueprint.group().addVec(), blueprint._rowLayout, null, Vec.T_NUM);
    final int nchunks = v0.nChunks();
    new MRTask() {

        @Override
        protected void setupLocal() {
            for (int i = 0; i < nchunks; i++) {
                Key k = v0.chunkKey(i);
                if (k.home()) {
                    int len = (int) (v0.espc()[i + 1] - v0.espc()[i]);
                    byte[] bytes = new byte[len];
                    new Random(i).nextBytes(bytes);
                    DKV.put(k, new C1NChunk(bytes), _fs);
                }
            }
        }
    }.doAllNodes();
    DKV.put(v0._key, v0);
    return v0;
}
Also used : Random(java.util.Random) MRTask(water.MRTask) Key(water.Key)

Aggregations

Key (water.Key)94 Frame (water.fvec.Frame)56 Test (org.junit.Test)42 Vec (water.fvec.Vec)21 File (java.io.File)18 NFSFileVec (water.fvec.NFSFileVec)17 Futures (water.Futures)10 Random (java.util.Random)7 H2OIllegalArgumentException (water.exceptions.H2OIllegalArgumentException)6 ValFrame (water.rapids.vals.ValFrame)6 DateTimeZone (org.joda.time.DateTimeZone)5 Model (hex.Model)4 SplitFrame (hex.SplitFrame)4 DeepLearning (hex.deeplearning.DeepLearning)4 DeepLearningModel (hex.deeplearning.DeepLearningModel)4 AppendableVec (water.fvec.AppendableVec)4 NewChunk (water.fvec.NewChunk)4 Grid (hex.grid.Grid)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3