Giter Club home page Giter Club logo

Comments (2)

wendycwong avatar wendycwong commented on June 11, 2024 1

I cobbled together the following and I can see that monotone constraint is set in the model:

assert H2OXGBoostEstimator.available() is True

# CPU Backend is forced for the results to be comparable
h2oParamsS = {"tree_method": "exact", "seed": 123, "backend": "cpu", "ntrees": 5}

trainFile = pyunit_utils.genTrainFrame(100, 10, enumCols=0, randseed=17)
print(trainFile)
myX = trainFile.names
y='response'
myX.remove(y)

h2oParamsS["monotone_constraints"] = {
    "C1": -1,
    "C3": 1,
    "C7": 1
}

gbm_params2 = {'learn_rate':[0.01, 0.02]}

gridM = H2OGridSearch(H2OXGBoostEstimator(**h2oParamsS), hyper_params=gbm_params2)
gridM.train(x=myX, y=y, training_frame=trainFile)
gridS = gridM.get_grid(sort_by="auc", decreasing=True)
best_gmb2 = gridS.models[0]
native_params2 = best_gmb2._model_json["output"]["native_parameters"].as_data_frame()
constraints2 = (native_params2[native_params2['name'] == "monotone_constraints"])['value'].values[0]
params = best_gmb2.get_params(deep=True)

h2oModelS = H2OXGBoostEstimator(**h2oParamsS)
h2oModelS.train(x=myX, y=y, training_frame=trainFile)

native_params = h2oModelS._model_json["output"]["native_parameters"].as_data_frame()
print(native_params)

constraints = (native_params[native_params['name'] == "monotone_constraints"])['value'].values[0]

assert constraints == u'(-1,0,1,0,0,0,1,0,0,0)'

Constraint2 is the same as constraints.

from h2o-3.

wendycwong avatar wendycwong commented on June 11, 2024

Something is wrong with get_params()...

from h2o-3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.