Skip to content
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

Merged
merged 6 commits into from Jun 1, 2018

Conversation

FaroukY
Copy link
Contributor

@FaroukY FaroukY commented May 26, 2018

No description provided.

Copy link
Collaborator

@iglesias iglesias left a 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)
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factory?

Copy link
Contributor Author

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)

Copy link
Member

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())
Copy link
Collaborator

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)?

Copy link
Contributor Author

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())
Copy link
Collaborator

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?

Copy link
Contributor Author

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

@FaroukY
Copy link
Contributor Author

FaroukY commented May 29, 2018

@iglesias once travis is green, this should be mergable right?

Copy link
Member

@vigsterkr vigsterkr left a 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"))
Copy link
Member

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()
Copy link
Member

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())

Copy link
Member

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

@FaroukY
Copy link
Contributor Author

FaroukY commented May 29, 2018

@vigsterkr Travis is green :)

@iglesias
Copy link
Collaborator

iglesias commented May 30, 2018 via email

@karlnapf
Copy link
Member

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)
Copy link
Member

@karlnapf karlnapf May 30, 2018

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)

@vigsterkr
Copy link
Member

@karlnapf currently discussing this already on #irc thnx

@karlnapf
Copy link
Member

Most changes look good. Rebase and let's merge

@FaroukY
Copy link
Contributor Author

FaroukY commented May 30, 2018

Changed all labels to new API now. this should address everything. Let's wait for Travis and rebase.

Copy link
Member

@vigsterkr vigsterkr left a 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)
Copy link
Member

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

@vigsterkr
Copy link
Member

this pr is mergable... its only that gcc actually times out... i've just restarted the job but this should be fine to merge!

@vigsterkr vigsterkr merged commit e1f02a5 into shogun-toolbox:develop Jun 1, 2018
@@ -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())
Copy link
Member

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?

Copy link
Member

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.

@FaroukY FaroukY deleted the evaluation_new_api branch June 2, 2018 04:43
ktiefe pushed a commit to ktiefe/shogun that referenced this pull request Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants