logistic-regression

Error when trying to pass custom metric in Caret package

泪湿孤枕 提交于 2021-02-10 19:32:29
问题 Related question - 1 I have a dataset like so: > head(training_data) year month channelGrouping visitStartTime visitNumber timeSinceLastVisit browser 1 2016 October Social 1477775021 1 0 Chrome 2 2016 September Social 1473037945 1 0 Safari 3 2017 July Organic Search 1500305542 1 0 Chrome 4 2017 July Organic Search 1500322111 2 16569 Chrome 5 2016 August Social 1471890172 1 0 Safari 6 2017 May Direct 1495146428 1 0 Chrome operatingSystem isMobile continent subContinent country source medium 1

Error when trying to pass custom metric in Caret package

亡梦爱人 提交于 2021-02-10 19:31:57
问题 Related question - 1 I have a dataset like so: > head(training_data) year month channelGrouping visitStartTime visitNumber timeSinceLastVisit browser 1 2016 October Social 1477775021 1 0 Chrome 2 2016 September Social 1473037945 1 0 Safari 3 2017 July Organic Search 1500305542 1 0 Chrome 4 2017 July Organic Search 1500322111 2 16569 Chrome 5 2016 August Social 1471890172 1 0 Safari 6 2017 May Direct 1495146428 1 0 Chrome operatingSystem isMobile continent subContinent country source medium 1

Multi-class Logistic Regression from scratch

这一生的挚爱 提交于 2021-02-10 14:18:14
问题 I am trying to implement from scratch the multiclass logistic regression but my implementation returns bad results. I believe the definition of the gradient function and the cost function is fine. Maybe there is a problem with how these functions are interacting with the minimize function. I have tried it but I could not find out what is wrong. Could you please cast some light? You can add the estimator 'myLR': myLR(**par_dict), with paramters par_dict= {'alpha': 0.1, 'maxit': 2000, 'opt

Multi-class Logistic Regression from scratch

我只是一个虾纸丫 提交于 2021-02-10 14:15:48
问题 I am trying to implement from scratch the multiclass logistic regression but my implementation returns bad results. I believe the definition of the gradient function and the cost function is fine. Maybe there is a problem with how these functions are interacting with the minimize function. I have tried it but I could not find out what is wrong. Could you please cast some light? You can add the estimator 'myLR': myLR(**par_dict), with paramters par_dict= {'alpha': 0.1, 'maxit': 2000, 'opt

Error with using the mlogit R function: the two indexes don't define unique observations

落爺英雄遲暮 提交于 2021-02-10 05:14:06
问题 I've got a problem with the mlogit funtion in R. My dataset looks like this: personID caseID altID choice a1 a2 a3 a4 1 1 1 1 3 0 3 1 1 1 2 0 1 3 0 1 1 1 3 0 4 4 4 4 1 2 1 0 2 2 1 3 1 2 2 1 2 3 1 3 etc.... I've tried running the following code, performing the model. setV2 <- mlogit.data(data = setV2, choice = "choice", shape = "long", alt.var = "altID", chid.var = "personID") m <- mlogit(choice ~ a1 + a2 + a3 + a4 | -1, rpar = c(a1 = "n", a2 = "n", a3 = "n", a4 = "n"), correlation = FALSE,

Error with using the mlogit R function: the two indexes don't define unique observations

我的未来我决定 提交于 2021-02-10 05:12:36
问题 I've got a problem with the mlogit funtion in R. My dataset looks like this: personID caseID altID choice a1 a2 a3 a4 1 1 1 1 3 0 3 1 1 1 2 0 1 3 0 1 1 1 3 0 4 4 4 4 1 2 1 0 2 2 1 3 1 2 2 1 2 3 1 3 etc.... I've tried running the following code, performing the model. setV2 <- mlogit.data(data = setV2, choice = "choice", shape = "long", alt.var = "altID", chid.var = "personID") m <- mlogit(choice ~ a1 + a2 + a3 + a4 | -1, rpar = c(a1 = "n", a2 = "n", a3 = "n", a4 = "n"), correlation = FALSE,

Gradient Boosting using gbm in R with distribution = “bernoulli”

折月煮酒 提交于 2021-02-08 09:26:21
问题 I am using gbm package in R and applying the 'bernoulli' option for distribution to build a classifier and i get unusual results of 'nan' and i'm unable to predict any classification results. But i do not encounter the same errors when i use 'adaboost'. Below is the sample code, i replicated the same errors with the iris dataset. ## using the iris data for gbm library(caret) library(gbm) data(iris) Data <- iris[1:100,-5] Label <- as.factor(c(rep(0,50), rep(1,50))) # Split the data into

Logistic regression: X has 667 features per sample; expecting 74869

元气小坏坏 提交于 2021-02-08 05:16:38
问题 Using a imdb movie reviews dataset i have made a logistic regression to predict the sentiment of the review. tfidf = TfidfVectorizer(strip_accents=None, lowercase=False, preprocessor=None, tokenizer=fill, use_idf=True, norm='l2', smooth_idf=True) y = df.sentiment.values X = tfidf.fit_transform(df.review) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1, test_size=0.3, shuffle=False) clf = LogisticRegressionCV(cv=5, scoring="accuracy", random_state=1, n_jobs=-1, verbose

R Step function looks for data in global environment, not inside defined function

╄→尐↘猪︶ㄣ 提交于 2021-02-07 10:15:07
问题 I have a problem with step forward regression and My understanding is that i don't pass argument Data correctly. I have the function: ForwardStep <- function(df,yName, Xs, XsMin) { Data <- df[, c(yName,Xs)] fit <- glm(formula = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), data = Data, family = binomial(link = "logit") ) ScopeFormula <- list(lower = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), upper = paste(yName, " ~ ", paste0(Xs, collapse = " + "))) result <- step(fit,

R Step function looks for data in global environment, not inside defined function

巧了我就是萌 提交于 2021-02-07 10:14:55
问题 I have a problem with step forward regression and My understanding is that i don't pass argument Data correctly. I have the function: ForwardStep <- function(df,yName, Xs, XsMin) { Data <- df[, c(yName,Xs)] fit <- glm(formula = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), data = Data, family = binomial(link = "logit") ) ScopeFormula <- list(lower = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), upper = paste(yName, " ~ ", paste0(Xs, collapse = " + "))) result <- step(fit,