Hi Kai,
You may find %in% easier than grep when multiple matches are needed:
match_strings<-c("MLH1","MSH2")
CRC<-data.frame(gene.all=c("MLH1","MSL1","MSH2","MCC3"))
CRC$MMR.gene<-ifelse(CRC$gene.all %in% match_strings,"Yes","No")
Composing your match strings before applying %in% may be more flex
In case it is of interest this problem can be solved with an
unconstrained optimizer,
here optim, like this:
proj <- function(x) x / sqrt(sum(x * x))
opt <- optim(c(0, 0, 1), function(x) f(proj(x)))
proj(opt$par)
## [1] 5.388907e-09 7.071068e-01 7.071068e-01
On Fri, May 21, 2021 a
Hello Agnes,
Yes, it is true, "xgboost" is not oriented for a "multi-label"
classification. "xgboost" can handle "multi-class" but not "multi-label".
Bue in "mlr", you can handle "multi-class" problems although not with
"xgboost" a base learner algorithm. You can see here how you can handle
that
Hi All,
Wanted to report what may be a bug or possibly an oversight, but I am unsure,
in the "foreign" packages in the read.spss() command,
https://cran.r-project.org/web/packages/foreign/index.html. When running the
following code,
input <- read.spss("[.sav file location]", to.data.frame = TR
Thank you for your reply.
As far as I can see xgboost package does not provide multilabel classification.
The mlr package uses a wrapper for xgboost, so I have used the package xgboost.
But I still have the problem with the hyperparameter tuning.
Did I understand you correctly?
Do you have any ot
One other suggestion. Per the posting guide linked below, statistical
issues such as your query on "hyperparameter tuning" are off topic on this
list, as are questions about specific nonstandard packages. You might try
posting on stats.stackexchange.com instead for help on such matters.
Bert Gunte
Hi,
A quick clarification:
The regular expression is a single quoted character vector, not a
character vector on either side of the | operator:
"MLH1|MSH2"
not:
"MLH1"|"MSH2"
The | is treated as a special character within the regular expression.
See ?regex.
grep(), when value = FALSE, r
Hi Rui,thank you for your suggestion.
but when I try the solution, I got message below:
Error in "MLH1" | "MSH2" : operations are possible only for numeric, logical
or complex types
does it mean, grepl can not work on character field?
Thanks,KaiOn Thursday, May 27, 2021, 01:37:58 AM PDT,
1. A web search on "xgboost R" brought up R package "xgboost" which you did
not mention. Did you not first try a web search or did you find that it did
not meet your needs?
2. Have you looked here: https://cran.r-project.org/web/views/Cluster.html
or here: https://cran.r-project.org/web/views/Mac
Hi all,
I want to do multilabel classification with XGBoost and tune hyperparameters.
With the mlr package this does not seem possible, see
https://stackoverflow.com/questions/67640953/feature-names-stored-in-object-and-newdata-are-different-using-mlr-package?noredirect=1#comment119651508_6764095
A tidyverse-ish solution would be
library(dplyr)
library(tidyr)
library(tibble)
# max cols to split values into
seps<-max(stringr::str_count(unlist(d1),"[/|]"))+1
d1 %>% pivot_longer(S1:S5, names_to="S") %>%
mutate(value=na_if(value,"w")) %>% separate(value,"[/|]",
into=LETTERS[1:seps], fill=
Hello,
ifelse needs a logical condition, not the value. Try grepl.
CRC$MMR.gene <- ifelse(grepl("MLH1"|"MSH2",CRC$gene.all), "Yes", "No")
Hope this helps,
Rui Barradas
Às 05:29 de 27/05/21, Kai Yang via R-help escreveu:
Hi List,
I wrote the code to create a new variable:
CRC$MMR.gene<-ifel
12 matches
Mail list logo