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
Updated cross validation examples to use new API (as far as I know) #4309
Conversation
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.
Follow-up whether the suggestions are possible. If not, we need to know clearly why.
CSVFile f_feats("../../data/fm_train_real.dat") | ||
CSVFile f_labels("../../data/label_train_twoclass.dat") | ||
File f_feats = csv_file("../../data/fm_train_real.dat") | ||
File f_labels = csv_file("../../data/label_train_twoclass.dat") | ||
|
||
#![create_features] | ||
Features feats = features(f_feats) |
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.
Can you do the CombinedFeatures and BinaryLabels below with the factories?
CSVFile f_feats("../../data/fm_train_real.dat") | ||
CSVFile f_labels("../../data/label_train_twoclass.dat") | ||
File f_feats = csv_file("../../data/fm_train_real.dat") | ||
File f_labels = csv_file("../../data/label_train_twoclass.dat") | ||
|
||
Features feats = features(f_feats) | ||
BinaryLabels labels(f_labels) |
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.
Factory?
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.
@iglesias There is a problem with StratifiedCrossValidationSplitting class. If you update to the new API, it leads to an error. Viktor told me he needs to discuss this with Heiko first since it is a design problem, so for now any label which is used with StratifiedCrossValidationSplitting has to use the old API (BinaryLabels)
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 changed this in #4313 to illustrate. You will have to rebase
@@ -52,10 +52,10 @@ real stddev = result.get_real("std_dev") | |||
#![get_fold_machine] | |||
CrossValidationStorage obs = mkl_obs.get_observation(0) | |||
CrossValidationFoldStorage fold = obs.get_fold(0) | |||
MKLClassification machine = MKLClassification:obtain_from_generic(fold.get_trained_machine()) | |||
MKLClassification machine_mkl = MKLClassification:obtain_from_generic(fold.get_trained_machine()) |
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.
Getter instead of obtain_from_generic (ofg)?
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.
For some reason, I tried the getter but it told me that the object is private. I will try again and see if I can do it
#![get_fold_machine] | ||
|
||
#![get_weights] | ||
CombinedKernel k = CombinedKernel:obtain_from_generic(machine.get_kernel()) | ||
CombinedKernel k = CombinedKernel:obtain_from_generic(machine_mkl.get_kernel()) |
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.
Getter in place of ofg?
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.
Same problem as above, tried the getter, but had problems with it. Will give it another go
d4a5cb7
to
456cc0d
Compare
@iglesias once travis is green, this should be mergable right? |
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.
the reasons of failures
#![get_fold_machine] | ||
|
||
#![get_weights] | ||
CombinedKernel k = CombinedKernel:obtain_from_generic(machine.get_kernel()) | ||
CombinedKernel k = kernel(machine_mkl.get("kernel")) |
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.
shouldnt this be simply
Kernel k = kernel(machine_mkl.get("kernel"))
CrossValidation cross(svm, feats, labels, splitting_strategy, evaluation_criterion) | ||
cross.set_num_runs(2) | ||
|
||
CrossValidationResult result = CrossValidationResult:obtain_from_generic(cross.evaluate()) | ||
CrossValidationResult result = cross.evaluate() |
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.
this assumes that one could explicitly cast CEvaluationResult
to CrossValidationResult
, which is not the case unfortunately.
for the time being there's no solution for this other than the one you had before:
CrossValidationResult result = CrossValidationResult:obtain_from_generic(cross.evaluate())
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.
EvalidationResult result = cross.evaluate()
should work
@vigsterkr Travis is green :) |
@FaroukY, still waiting here for you to get back to the review.
…On 29 May 2018 at 22:20, Elfarouk Yasser ***@***.***> wrote:
@vigsterkr <https://github.com/vigsterkr> Travis is green :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4309 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABGrdvr9wu3ObylGP03ZrOdMg0qfHhAiks5t3a2fgaJpZM4UOwrB>
.
|
There is a conflict, you will have to rebase |
svm.set_kernel(kernel) | ||
Machine libsvm = machine("LibSVM") | ||
Machine svm = machine("MKLClassification", kernel=combined_kernel) | ||
svm.put("interleaved_optimization", False) |
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.
as said many many times before, pls put this into the kwargs
Machine svm = machine("MKLClassification", kernel=combined_kernel, interleaved_optimization=False, svm=libsvm)
@karlnapf currently discussing this already on #irc thnx |
Most changes look good. Rebase and let's merge |
0a2d37c
to
da01ef0
Compare
Changed all labels to new API now. this should address everything. Let's wait for Travis and rebase. |
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.
make sure that things are tested locally prior sending in an update :)
CrossValidation cross(svm, feats, labs, splitting_strategy, evaluation_criterion) | ||
StratifiedCrossValidationSplitting splitting_strategy(labels, 5) | ||
Evaluation evaluation_criterion = evaluation("AccuracyMeasure") | ||
CrossValidation cross(svm, feats, labels, splitting_strategy, evaluation_criterion) |
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.
labs
? please rename labs
to labels
otherwise this will fail... as it fails now
this pr is mergable... its only that gcc actually times out... i've just restarted the job but this should be fine to merge! |
@@ -8,11 +8,11 @@ Machine svm = machine("LibLinear") | |||
svm.put("liblinear_solver_type", enum LIBLINEAR_SOLVER_TYPE.L2R_L2LOSS_SVC) | |||
|
|||
StratifiedCrossValidationSplitting splitting_strategy(labs, 5) | |||
AccuracyMeasure evaluation_criterion() | |||
Evaluation evaluation_criterion = evaluation("AccuracyMeasure") | |||
CrossValidation cross(svm, feats, labs, splitting_strategy, evaluation_criterion) | |||
cross.set_num_runs(2) | |||
|
|||
CrossValidationResult result = CrossValidationResult:obtain_from_generic(cross.evaluate()) |
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.
EvaluationResult result = cross.evaluate()
didnt work?
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.
my mistake, just testing the patch and pushing once done.
No description provided.