-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add metaexample for CHAIDTree Regression #5065
Changes from 9 commits
a3dcdfd
b89ba4c
1f9edbc
95a2af7
40613e8
7c843e2
4d666ac
f735ae1
ea5a144
b66ca9a
ad7341f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+1 −0 | testsuite/meta/regression/chaid_tree.dat |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||
File f_feats_train = read_csv("@SHOGUN_DATA@/regression_1d_linear_features_train.dat") | ||||
File f_feats_test = read_csv("@SHOGUN_DATA@/regression_1d_linear_features_test.dat") | ||||
File f_labels_train = read_csv("@SHOGUN_DATA@/regression_1d_linear_labels_train.dat") | ||||
|
||||
#![create_features] | ||||
Features feats_train = create_features(f_feats_train) | ||||
Features feats_test = create_features(f_feats_test) | ||||
Labels labels_train = create_labels(f_labels_train) | ||||
#![create_features] | ||||
|
||||
#![set_feature_types] | ||||
IntVector ft(1) | ||||
ft[0] = 2 | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @karlnapf this is causing issues. In octave this becomes a scalar value :( I wrote a fix for this but it's in another branch, not yet merged.. Also this throws an error in the meta example, but ctest doesn't pick this up (I had this issue before) and I am not sure why. The test only fails when comparing the serialised outputs in the integration test, because this will not have serialised anything because of the exception thrown when you put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, unless we merge your fix this meta example will fail only in Octave, right? Could it be possible to merge this PR anyway, but somehow excluding it from testing with Octave (since it is broken atm)? Just to not have to put this on hold indefinitely... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe @Hephaestus12 can just fix it here? All you need to do is replace shogun/src/interfaces/swig/shogun.i Line 199 in 3041ea0
with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'll do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope this works :D |
||||
#![set_feature_types] | ||||
|
||||
#![create_machine] | ||||
Machine chaidtree = create_machine("CHAIDTree", labels=labels_train, dependent_vartype=2, feature_types=ft, num_breakpoints=50) | ||||
#![create_machine] | ||||
|
||||
#![train_and_apply] | ||||
chaidtree.train(feats_train) | ||||
Labels labels_predict = chaidtree.apply(feats_test) | ||||
#![train_and_apply] | ||||
|
||||
#![extract_weights_labels] | ||||
RealVector labels_vector = labels_predict.get_real_vector("labels") | ||||
#![extract_weights_labels] |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1392,14 +1392,14 @@ void CHAIDTree::init() | |
m_cont_breakpoints=SGMatrix<float64_t>(); | ||
m_num_breakpoints=0; | ||
|
||
SG_ADD(&m_weights,"m_weights", "weights", ParameterProperties::READONLY); | ||
SG_ADD(&m_weights_set,"m_weights_set", "weights set", ParameterProperties::READONLY); | ||
SG_ADD(&m_feature_types,"m_feature_types", "feature types", ParameterProperties::SETTING); | ||
SG_ADD(&m_dependent_vartype,"m_dependent_vartype", "dependent variable type", ParameterProperties::SETTING); | ||
SG_ADD(&m_max_tree_depth,"m_max_tree_depth", "max tree depth", ParameterProperties::HYPER); | ||
SG_ADD(&m_min_node_size,"m_min_node_size", "min node size", ParameterProperties::SETTING); | ||
SG_ADD(&m_alpha_merge,"m_alpha_merge", "alpha-merge", ParameterProperties::HYPER); | ||
SG_ADD(&m_alpha_split,"m_alpha_split", "alpha-split", ParameterProperties::HYPER); | ||
SG_ADD(&m_cont_breakpoints,"m_cont_breakpoints", "breakpoints in continuous attributes", ParameterProperties::SETTING); | ||
SG_ADD(&m_num_breakpoints,"m_num_breakpoints", "number of breakpoints", ParameterProperties::HYPER); | ||
SG_ADD(&m_weights,"weights", "weights", ParameterProperties::READONLY); | ||
SG_ADD(&m_weights_set,"weights_set", "weights set", ParameterProperties::READONLY); | ||
SG_ADD(&m_feature_types,"feature_types", "feature types", ParameterProperties::SETTING); | ||
SG_ADD(&m_dependent_vartype,"dependent_vartype", "dependent variable type", ParameterProperties::SETTING); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This causes the notebooks to fail: Should be simple to fix: open the notebook and edit the name in there as well :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do I run test the notebooks on my local machine? Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a script for doing that https://github.com/shogun-toolbox/shogun/blob/develop/scripts/test_notebooks.sh. The link Heiko pasted here above will show also how to use it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesnt. You would have to compile shogun with the python interface, make sure you can load it from python, and then open the notebook in jupyter notebook. However, you might be able to do a simple hack here:
As this is such a simple change, that should do it without the need for you running it locally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have already pushed the code after making those changes. :) |
||
SG_ADD(&m_max_tree_depth,"max_tree_depth", "max tree depth", ParameterProperties::HYPER); | ||
SG_ADD(&m_min_node_size,"min_node_size", "min node size", ParameterProperties::SETTING); | ||
SG_ADD(&m_alpha_merge,"alpha_merge", "alpha-merge", ParameterProperties::HYPER); | ||
SG_ADD(&m_alpha_split,"alpha_split", "alpha-split", ParameterProperties::HYPER); | ||
SG_ADD(&m_cont_breakpoints,"cont_breakpoints", "breakpoints in continuous attributes", ParameterProperties::SETTING); | ||
SG_ADD(&m_num_breakpoints,"num_breakpoints", "number of breakpoints", ParameterProperties::HYPER); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot some, I remember seeing one name in a "get" call...double check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to this:
shogun/doc/ipython-notebooks/multiclass/Tree/DecisionTrees.ipynb
Line 613 in 123f512
I don't think we should change this right? As it isn't related to CHAID tree? As then we will have to make some other change in the source code related to
C45ClassifierTree
Also, the other one is :
shogun/doc/ipython-notebooks/multiclass/Tree/DecisionTrees.ipynb
Line 643 in 123f512
This one too, is an instance of
C45ClassifierTree
. Should I change these two instances too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry. of course you are right!
We will see it in the CI for the notebooks