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

modnames error #9

Open
c1au6i0 opened this issue Mar 14, 2019 · 2 comments
Open

modnames error #9

c1au6i0 opened this issue Mar 14, 2019 · 2 comments

Comments

@c1au6i0
Copy link

c1au6i0 commented Mar 14, 2019

I am getting an error when I set the argument modnames.

Here a reproducible example:

df <- read.csv("https://24v1ba.bn.files.1drv.com/y4msuh_tu65FeAE-CEp2SCQLTjZHhKalM9kuzlq19IN4Mu7GUWa7wxwSvtghhd5o_6VAL6S_GveZeqG8CyHa-9lzrhCRkew30v61z5t9f8a2kLp1xBMXtnaKe-GV1IDwmlS-LmOg0bkqpUYdiQX_4xcgX6dJBVqPe_1llKZ2sZhcL9LGiVtsYdWEnmNu_EHKl39/df.csv?download&psid=1")

names(df)

[1] "alpha"    "lambda"   "pred"     "obs"      "Yes"      "No"       "rowIndex" "Resample" "mod"     

and both the following lines generate an error

cvdat <- mmdata(nfold_df = df, score_cols = 5, lab_col = 4, fold_col = 8, modnames = 9)
cvdat <- mmdata(nfold_df = df, score_cols = 5, lab_col = 4, fold_col = 8, modnames = c("glmnet"))
Error: Invalid modnames and/or dsids

What am I doing wrong?

Thanks

@takayasaito
Copy link
Member

Sorry for my late response. I somehow overlooked your comment.

The length of modnames vector must be the same number of your validation sets. For instance, it should be modnames = rep("model_name", 10) if your data contains 10-fold cross-validation for a single model/classifier. It can be modnames = rep(c("A", "B"), each=5) for 5-fold cross-validation for two classifiers A and B.

Alternatively, you can use auto-expansion by specifying dsids and modnames at the same time. For instance, dsids = 1:5, modnames = c("A", "B") expands to dsids = c(1,2,3,4,5,1,2,3,4,5), modnames = c("A","A","A","A","A","B","B","B","B","B") inside the mmdata function.

The auto-expansion approach requires that the product of the lengths of dsids and modnames should be matched with the total number of your validation sets. For example, length(dsids) * length(modnames) = 5 * 2 = 10 indicates that it will be extended for a data set of 5-fold cross-validation with two classifiers.

@c1au6i0
Copy link
Author

c1au6i0 commented Apr 12, 2019

Great! Got it. Thank you so much @takayasaito :)

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