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

Problem with new API (StatisfiedCrossValidation) #4299

Closed
FaroukY opened this issue May 23, 2018 · 1 comment
Closed

Problem with new API (StatisfiedCrossValidation) #4299

FaroukY opened this issue May 23, 2018 · 1 comment

Comments

@FaroukY
Copy link
Contributor

FaroukY commented May 23, 2018

It seems there is a problem with the new API in StratisfiedCrossValidation. The following example fails with error:

[ERROR] In file /tmp/src/shogun/src/shogun/evaluation/StratifiedCrossValidationSplitting.cpp line 44: Multiclass or binary labels required for stratified crossvalidation

Example.sg:

#  Cross Validation for Binary Classifier
File f_feats_train = csv_file("../../data/classifier_binary_2d_linear_features_train.dat")
File f_feats_test = csv_file("../../data/classifier_binary_2d_linear_features_test.dat")
File f_labels_train = csv_file("../../data/classifier_binary_2d_linear_labels_train.dat")
File f_labels_test = csv_file("../../data/classifier_binary_2d_linear_labels_test.dat")
Math:init_random(2)

#![create_features]
Features features_train = features(f_feats_train)
Labels labels_train = labels(f_labels_train)
Features features_test = features(f_feats_test)
Labels labels_test = labels(f_labels_test)
#![create_features]

#![create_cross_validation]
StratifiedCrossValidationSplitting splitting_strategy(labels_train, 2)
#![create_cross_validation]

Changing this to the following runs fine:

#  Cross Validation for Binary Classifier
File f_feats_train = csv_file("../../data/classifier_binary_2d_linear_features_train.dat")
File f_feats_test = csv_file("../../data/classifier_binary_2d_linear_features_test.dat")
File f_labels_train = csv_file("../../data/classifier_binary_2d_linear_labels_train.dat")
File f_labels_test = csv_file("../../data/classifier_binary_2d_linear_labels_test.dat")
Math:init_random(2)

#![create_features]
Features features_train = features(f_feats_train)
Labels labels_train = labels(f_labels_train)
BinaryLabels old_API(f_labels_train)
Features features_test = features(f_feats_test)
Labels labels_test = labels(f_labels_test)
#![create_features]

#![create_cross_validation]
StratifiedCrossValidationSplitting splitting_strategy(old_API, 2)
#![create_cross_validation]

@karlnapf
Copy link
Member

Yep, that is to be expected. You will need to use the conversion methods in there for now.
See #4297 for example

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

No branches or pull requests

2 participants