Skip to content

Commit 5d41630

Browse files
committed
Fix failed tests
1 parent d19bd44 commit 5d41630

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

h2o-algos/src/main/java/hex/knn/KNN.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class KNNDriver extends Driver {
4949
public void computeImpl() {
5050
KNNModel model = null;
5151
Frame result = new Frame(Key.make("KNN_distances"));
52-
Frame tmpResult = null;
5352
try {
5453
init(true); // Initialize parameters
5554
if (error_count() > 0) {
@@ -72,12 +71,15 @@ public void computeImpl() {
7271
query[j] = train.vec(j).chunkForChunkIdx(i).deepCopy();
7372
}
7473
KNNDistanceTask task = new KNNDistanceTask(_parms._k, query, KNNDistanceFactory.createDistance(_parms._distance), idColumnIndex, idColumn, idType, responseColumnIndex, responseColumn);
75-
tmpResult = task.doAll(train).outputFrame();
74+
Frame tmpResult = task.doAll(train).outputFrame();
75+
Scope.untrack(tmpResult);
76+
7677
// merge result from a chunk
7778
result = result.add(tmpResult);
7879
}
79-
DKV.put(result._key, result);
80-
model._output.setDistancesKey(result._key);
80+
Key<Frame> key = result._key;
81+
DKV.put(key, result);
82+
model._output.setDistancesKey(key);
8183
Scope.untrack(result);
8284

8385
model.update(_job);
@@ -90,9 +92,6 @@ public void computeImpl() {
9092
if (model != null) {
9193
model.unlock(_job);
9294
}
93-
if (tmpResult != null) {
94-
tmpResult.remove();
95-
}
9695
}
9796
}
9897
}

h2o-algos/src/test/java/hex/knn/KNNTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public void testIris() {
5555
ModelMetricsMultinomial mm1 = (ModelMetricsMultinomial) knn._output._training_metrics;
5656
Assert.assertEquals(mm.auc(), mm1.auc(), 0);
5757

58-
// test after KNN API will be ready
59-
//knn.testJavaScoring(fr, preds, 0);
60-
58+
knn.testJavaScoring(fr, preds, 0);
6159
} finally {
6260
if (knn != null){
6361
knn.delete();

h2o-py/tests/testdir_sklearn/pyunit_sklearn_classification_all_estimators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def make_tests(classifier):
149149

150150

151151
failing = [
152-
'H2OStackedEnsembleClassifier', 'H2OUpliftRandomForestClassifier' # needs a separate test (requires models as parameters)
152+
'H2OStackedEnsembleClassifier', 'H2OUpliftRandomForestClassifier', 'H2OKnnClassifier' # needs a separate test (requires models as parameters)
153153
]
154154
classifiers = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
155155
if name.endswith('Classifier') and name not in ['H2OAutoMLClassifier']+failing]

h2o-py/tests/testdir_sklearn/pyunit_sklearn_generic_all_estimators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def make_tests(classifier):
200200
'H2OUpliftRandomForestEstimator', # generic part is not implemented yet
201201
'H2ODecisionTreeEstimator', # generic part is not implemented yet
202202
'H2OAdaBoostEstimator', # generic part is not implemented yet or test needs to be adjusted just for classification
203+
'H2OKnnEstimator' # generic part is not implemented yet
203204
]
204205
estimators = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
205206
if name.endswith('Estimator') and name not in ['H2OAutoMLEstimator'] + failing]

h2o-py/tests/testdir_sklearn/pyunit_sklearn_regression_all_estimators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def make_tests(classifier):
139139
'H2OStackedEnsembleRegressor', # needs a separate test (requires models as parameters),
140140
'H2OUpliftRandomForestRegressor', # does not support regression yet
141141
'H2ODecisionTreeRegressor', # does not support regression yet
142-
'H2OAdaBoostRegressor' # does not support regression yet
142+
'H2OAdaBoostRegressor', # does not support regression yet
143+
'H2OKnnRegressor' # does not support regression
143144
]
144145
regressors = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
145146
if name.endswith('Regressor') and name not in ['H2OAutoMLRegressor']+failing]

h2o-py/tests_rest_smoke/testdir_multi_jvm/test_rest_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
algos = ['coxph', 'kmeans', 'deeplearning', 'drf', 'glm', 'gbm', 'pca', 'naivebayes', 'glrm', 'svd', 'isotonicregression',
2424
'psvm', 'aggregator', 'word2vec', 'stackedensemble', 'xgboost', 'isolationforest', 'gam',
2525
'generic', 'targetencoder', 'rulefit', 'extendedisolationforest', 'anovaglm', 'modelselection',
26-
'upliftdrf', 'infogram', 'dt', 'adaboost', 'hglm']
26+
'upliftdrf', 'infogram', 'dt', 'adaboost', 'hglm', 'knn']
2727

2828
algo_additional_default_params = { 'grep' : { 'regex' : '.*' },
2929
'kmeans' : { 'k' : 2 },

h2o-r/tests/testdir_algos/knn/runit_knn_smoke.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source("../../../scripts/h2o-r-test-setup.R")
55

66
knn.smoke <- function() {
77
iris.hex <- h2o.uploadFile( locate("smalldata/iris/iris.csv"))
8-
iris.knn <- h2o.knn(x=1:4, training_frame=iris.hex, k = 3, distance="euclidean", seed = 1234)
8+
iris.knn <- h2o.knn(x=1:4, y=5, training_frame=iris.hex, k=3 , distance="euclidean", seed=1234)
99

1010
# Score test data with different default auc_type (previous was "NONE", so no AUC calculation)
1111
perf <- h2o.performance(iris.knn, test.hex, auc_type="WEIGHTED_OVO")

0 commit comments

Comments
 (0)