本文整理了Java中water.Job.get()
方法的一些代码示例,展示了Job.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.get()
方法的具体详情如下:
包路径:water.Job
类名称:Job
方法名:get
[英]Blocks and get result of this job.
The call blocks on working task which was passed via #start(H2OCountedCompleter) method and returns the result which is fetched from UKV based on job destination key.
[中]块并获取此作业的结果。
调用阻塞通过#start(H2OCountedCompleter)方法传递的工作任务,并返回基于作业目标键从UKV获取的结果。
代码示例来源:origin: h2oai/h2o-3
/**
* Holds until AutoML's job is completed, if a job exists.
*/
public void get() {
if (job != null) job.get();
}
代码示例来源:origin: h2oai/h2o-3
@Override
public void stop() {
for (Frame f : tempFrames) f.delete();
tempFrames = null;
if (null == jobs) return; // already stopped
for (Job j : jobs) j.stop();
for (Job j : jobs) j.get(); // Hold until they all completely stop.
jobs = null;
// TODO: add a failsafe, if we haven't marked off as much work as we originally intended?
// If we don't, we end up with an exceptional completion.
}
代码示例来源:origin: h2oai/h2o-3
private static KMeansModel doSeed( KMeansModel.KMeansParameters parms, long seed ) {
parms._seed = seed;
KMeans job = new KMeans(parms);
KMeansModel kmm = job.trainModel().get();
checkConsistency(kmm);
for( int i=0; i<kmm._output._k[kmm._output._k.length-1]; i++ )
Assert.assertTrue( "Seed: "+seed, kmm._output._size[i] != 0 );
return kmm;
}
代码示例来源:origin: h2oai/h2o-3
private GLMModel prepareGLMModel(String dataset, String[] ignoredColumns, String response, GLMModel.GLMParameters.Family family) {
Frame f = parse_test_file(dataset);
try {
GLMModel.GLMParameters params = new GLMModel.GLMParameters();
params._train = f._key;
params._ignored_columns = ignoredColumns;
params._response_column = response;
params._family = family;
return new GLM(params).trainModel().get();
} finally {
if (f!=null) f.delete();
}
}
代码示例来源:origin: h2oai/h2o-3
private IsolationForestModel prepareIsoForModel(String dataset, String[] ignoredColumns, int ntrees) {
Frame f = parse_test_file(dataset);
try {
IsolationForestModel.IsolationForestParameters ifParams = new IsolationForestModel.IsolationForestParameters();
ifParams._train = f._key;
ifParams._ignored_columns = ignoredColumns;
ifParams._ntrees = ntrees;
ifParams._score_each_iteration = true;
return new IsolationForest(ifParams).trainModel().get();
} finally {
if (f!=null) f.delete();
}
}
代码示例来源:origin: h2oai/h2o-3
@Ignore
@Test public void testAirlines() {
Frame frame = parse_test_file("smalldata/airlines/allyears2k_headers.zip");
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._target_num_exemplars = 500;
parms._rel_tol_num_exemplars = 0.05;
long start = System.currentTimeMillis();
AggregatorModel agg = new Aggregator(parms).trainModel().get(); // 0.179
System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds"); agg.checkConsistency();
frame.delete();
Frame output = agg._output._output_frame.get();
output.remove();
checkNumExemplars(agg);
agg.remove();
}
代码示例来源:origin: h2oai/h2o-3
@Test public void testCovtype() {
Frame frame = parse_test_file("smalldata/covtype/covtype.20k.data");
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._target_num_exemplars = 500;
parms._rel_tol_num_exemplars = 0.05;
long start = System.currentTimeMillis();
AggregatorModel agg = new Aggregator(parms).trainModel().get(); // 0.179
System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds"); agg.checkConsistency();
frame.delete();
Frame output = agg._output._output_frame.get();
Log.info("Exemplars: " + output.toString());
output.remove();
checkNumExemplars(agg);
agg.remove();
}
代码示例来源:origin: h2oai/h2o-3
@Ignore
@Test public void testMNIST() {
Frame frame = parse_test_file("bigdata/laptop/mnist/train.csv.gz");
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
long start = System.currentTimeMillis();
AggregatorModel agg = new Aggregator(parms).trainModel().get();
System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds"); agg.checkConsistency();
frame.delete();
Frame output = agg._output._output_frame.get();
// Log.info("Exemplars: " + output);
output.remove();
Log.info("Number of exemplars: " + agg._exemplars.length);
checkNumExemplars(agg);
agg.remove();
}
代码示例来源:origin: h2oai/h2o-3
@Test public void testInts() {
QuantileModel kmm = null;
Frame fr = null;
try {
fr = ArrayUtils.frame(new double[][]{{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
{2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}});
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
代码示例来源:origin: h2oai/h2o-3
void trainSamplesPerIteration(int samples, int expected) {
DeepWaterModel m = null;
Frame tr = null;
try {
DeepWaterParameters p = new DeepWaterParameters();
p._backend = getBackend();
p._train = (tr=parse_test_file("bigdata/laptop/deepwater/imagenet/cat_dog_mouse.csv"))._key;
p._response_column = "C2";
p._learning_rate = 1e-3;
p._epochs = 3;
p._train_samples_per_iteration = samples;
m = new DeepWater(p).trainModel().get();
Assert.assertEquals(expected,m.iterations);
} finally {
if (m!=null) m.delete();
if (tr!=null) tr.remove();
}
}
代码示例来源:origin: h2oai/h2o-3
@Test public void test50pct() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1.56386606237}, {0.812834256224}, {3.68417563302}, {3.12702210880}, {5.51277746586}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][5] == d[3][0]);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
代码示例来源:origin: h2oai/h2o-3
@Test public void testInterpolate1() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1}, {1}, {2}, {2}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
parms._probs = new double[]{0.5};
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][0] == 1.5);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
@Test public void testInterpolate2() {
代码示例来源:origin: h2oai/h2o-3
@Test public void testInterpolate2() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1}, {1}, {3}, {2}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
parms._probs = new double[]{0.5};
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][0] == 1.5);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
@Test public void testInterpolateLow() {
代码示例来源:origin: h2oai/h2o-3
@Test public void testInterpolateHigh() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1}, {2}, {3}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
parms._probs = new double[]{0.51};
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][0] == 2.02);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
@Test public void testInterpolateHighWeighted() {
代码示例来源:origin: h2oai/h2o-3
@Test public void testDirectMatch() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1}, {1}, {1}, {2}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
parms._probs = new double[]{0.5};
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][0] == 1);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
@Test public void testInterpolate1() {
代码示例来源:origin: h2oai/h2o-3
@Test public void testInterpolateLow() {
QuantileModel kmm = null;
Frame fr = null;
try {
double[][] d = new double[][]{{1}, {2}, {3}};
fr = ArrayUtils.frame(d);
QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
parms._train = fr._key;
parms._probs = new double[]{0.49};
Job<QuantileModel> job = new Quantile(parms).trainModel();
kmm = job.get();
job.remove();
Assert.assertTrue(kmm._output._quantiles[0][0] == 1.98);
} finally {
if( fr != null ) fr .remove();
if( kmm != null ) kmm.delete();
}
}
@Test public void testInterpolateHigh() {
代码示例来源:origin: h2oai/h2o-3
@Test public void testAbalone() {
Scope.enter();
GLMModel model = null;
try {
Frame fr = parse_test_file("smalldata/glm_test/Abalone.gz");
Scope.track(fr);
GLMParameters params = new GLMParameters(Family.gaussian);
params._train = fr._key;
params._response_column = fr._names[8];
params._alpha = new double[]{1.0};
params._lambda_search = true;
GLM glm = new GLM(params);
model = glm.trainModel().get();
testScoring(model,fr);
} finally {
if( model != null ) model.delete();
Scope.exit();
}
}
代码示例来源:origin: h2oai/h2o-3
private GBMModel trainGbm(final int ntrees) {
Frame f = Scope.track(parse_test_file("smalldata/logreg/prostate.csv"));
final String response = "CAPSULE";
f.replace(f.find(response), f.vec(response).toCategoricalVec()).remove();
DKV.put(f._key, f);
GBMModel.GBMParameters gbmParams = new GBMModel.GBMParameters();
gbmParams._seed = 123;
gbmParams._train = f._key;
gbmParams._ignored_columns = new String[]{"ID"};
gbmParams._response_column = response;
gbmParams._ntrees = ntrees;
gbmParams._score_each_iteration = true;
return(GBMModel) Scope.track_generic(new GBM(gbmParams).trainModel().get());
}
代码示例来源:origin: h2oai/h2o-3
private GBMModel prepareGBMModel(String dataset, String[] ignoredColumns, String response, boolean classification, int ntrees) {
Frame f = parse_test_file(dataset);
try {
if (classification && !f.vec(response).isCategorical()) {
f.replace(f.find(response), f.vec(response).toCategoricalVec()).remove();
DKV.put(f._key, f);
}
GBMModel.GBMParameters gbmParams = new GBMModel.GBMParameters();
gbmParams._train = f._key;
gbmParams._ignored_columns = ignoredColumns;
gbmParams._response_column = response;
gbmParams._ntrees = ntrees;
gbmParams._score_each_iteration = true;
return new GBM(gbmParams).trainModel().get();
} finally {
if (f!=null) f.delete();
}
}
代码示例来源:origin: h2oai/h2o-3
private DRFModel prepareDRFModel(String dataset, String[] ignoredColumns, String response, boolean classification, int ntrees) {
Frame f = parse_test_file(dataset);
try {
if (classification && !f.vec(response).isCategorical()) {
f.replace(f.find(response), f.vec(response).toCategoricalVec()).remove();
DKV.put(f._key, f);
}
DRFModel.DRFParameters drfParams = new DRFModel.DRFParameters();
drfParams._train = f._key;
drfParams._ignored_columns = ignoredColumns;
drfParams._response_column = response;
drfParams._ntrees = ntrees;
drfParams._score_each_iteration = true;
return new DRF(drfParams).trainModel().get();
} finally {
if (f!=null) f.delete();
}
}
内容来源于网络,如有侵权,请联系作者删除!