Skip to content

Commit

Permalink
Fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maurever committed Jan 15, 2025
1 parent d19bd44 commit 5d41630
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
13 changes: 6 additions & 7 deletions h2o-algos/src/main/java/hex/knn/KNN.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class KNNDriver extends Driver {
public void computeImpl() {
KNNModel model = null;
Frame result = new Frame(Key.make("KNN_distances"));
Frame tmpResult = null;
try {
init(true); // Initialize parameters
if (error_count() > 0) {
Expand All @@ -72,12 +71,15 @@ public void computeImpl() {
query[j] = train.vec(j).chunkForChunkIdx(i).deepCopy();
}
KNNDistanceTask task = new KNNDistanceTask(_parms._k, query, KNNDistanceFactory.createDistance(_parms._distance), idColumnIndex, idColumn, idType, responseColumnIndex, responseColumn);
tmpResult = task.doAll(train).outputFrame();
Frame tmpResult = task.doAll(train).outputFrame();
Scope.untrack(tmpResult);

// merge result from a chunk
result = result.add(tmpResult);
}
DKV.put(result._key, result);
model._output.setDistancesKey(result._key);
Key<Frame> key = result._key;
DKV.put(key, result);
model._output.setDistancesKey(key);
Scope.untrack(result);

model.update(_job);
Expand All @@ -90,9 +92,6 @@ public void computeImpl() {
if (model != null) {
model.unlock(_job);
}
if (tmpResult != null) {
tmpResult.remove();
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions h2o-algos/src/test/java/hex/knn/KNNTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public void testIris() {
ModelMetricsMultinomial mm1 = (ModelMetricsMultinomial) knn._output._training_metrics;
Assert.assertEquals(mm.auc(), mm1.auc(), 0);

// test after KNN API will be ready
//knn.testJavaScoring(fr, preds, 0);

knn.testJavaScoring(fr, preds, 0);
} finally {
if (knn != null){
knn.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def make_tests(classifier):


failing = [
'H2OStackedEnsembleClassifier', 'H2OUpliftRandomForestClassifier' # needs a separate test (requires models as parameters)
'H2OStackedEnsembleClassifier', 'H2OUpliftRandomForestClassifier', 'H2OKnnClassifier' # needs a separate test (requires models as parameters)
]
classifiers = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
if name.endswith('Classifier') and name not in ['H2OAutoMLClassifier']+failing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def make_tests(classifier):
'H2OUpliftRandomForestEstimator', # generic part is not implemented yet
'H2ODecisionTreeEstimator', # generic part is not implemented yet
'H2OAdaBoostEstimator', # generic part is not implemented yet or test needs to be adjusted just for classification
'H2OKnnEstimator' # generic part is not implemented yet
]
estimators = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
if name.endswith('Estimator') and name not in ['H2OAutoMLEstimator'] + failing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def make_tests(classifier):
'H2OStackedEnsembleRegressor', # needs a separate test (requires models as parameters),
'H2OUpliftRandomForestRegressor', # does not support regression yet
'H2ODecisionTreeRegressor', # does not support regression yet
'H2OAdaBoostRegressor' # does not support regression yet
'H2OAdaBoostRegressor', # does not support regression yet
'H2OKnnRegressor' # does not support regression
]
regressors = [cls for name, cls in inspect.getmembers(h2o.sklearn, inspect.isclass)
if name.endswith('Regressor') and name not in ['H2OAutoMLRegressor']+failing]
Expand Down
2 changes: 1 addition & 1 deletion h2o-py/tests_rest_smoke/testdir_multi_jvm/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
algos = ['coxph', 'kmeans', 'deeplearning', 'drf', 'glm', 'gbm', 'pca', 'naivebayes', 'glrm', 'svd', 'isotonicregression',
'psvm', 'aggregator', 'word2vec', 'stackedensemble', 'xgboost', 'isolationforest', 'gam',
'generic', 'targetencoder', 'rulefit', 'extendedisolationforest', 'anovaglm', 'modelselection',
'upliftdrf', 'infogram', 'dt', 'adaboost', 'hglm']
'upliftdrf', 'infogram', 'dt', 'adaboost', 'hglm', 'knn']

algo_additional_default_params = { 'grep' : { 'regex' : '.*' },
'kmeans' : { 'k' : 2 },
Expand Down
2 changes: 1 addition & 1 deletion h2o-r/tests/testdir_algos/knn/runit_knn_smoke.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source("../../../scripts/h2o-r-test-setup.R")

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

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

0 comments on commit 5d41630

Please sign in to comment.