in R, elastic net missing class in classification modelRemove rows with all or some NAs (missing values) in data.frameA simple explanation of Naive Bayes ClassificationErrors when running Caret package in RR and PCA Explanation for machine learningStatistical Learning--Classification model with LASSO prediction errorError using glmnet regression with metric as ROC in CaretError with class probabilities using R caretR - caret::train “random forest” parametersHow to adjust classification metrics to imbalanced binary classification data with `class_weight` in sklearnPredictive Analytics - “why” factor & model interpretability
Draw simple lines in Inkscape
What are these boxed doors outside store fronts in New York?
What does "enim et" mean?
How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?
I probably found a bug with the sudo apt install function
What is the offset in a seaplane's hull?
How to type dʒ symbol (IPA) on Mac?
"which" command doesn't work / path of Safari?
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
Why is "Reports" in sentence down without "The"
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
My colleague's body is amazing
Should I join an office cleaning event for free?
How does one intimidate enemies without having the capacity for violence?
LED on same Pin as Toggle Switch, not illuminating
Is Social Media Science Fiction?
Download, install and reboot computer at night if needed
Is it possible to do 50 km distance without any previous training?
Why CLRS example on residual networks does not follows its formula?
Why do we use polarized capacitor?
Circuitry of TV splitters
Calculus Optimization - Point on graph closest to given point
Japan - Any leeway for max visa duration due to unforeseen circumstances?
What defenses are there against being summoned by the Gate spell?
in R, elastic net missing class in classification model
Remove rows with all or some NAs (missing values) in data.frameA simple explanation of Naive Bayes ClassificationErrors when running Caret package in RR and PCA Explanation for machine learningStatistical Learning--Classification model with LASSO prediction errorError using glmnet regression with metric as ROC in CaretError with class probabilities using R caretR - caret::train “random forest” parametersHow to adjust classification metrics to imbalanced binary classification data with `class_weight` in sklearnPredictive Analytics - “why” factor & model interpretability
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
In the cousera.org Machine Learning course assignment project, I adopt elastic net model to find the best classification model.
The training and testing data are compared to find what should be kept as training. I have checked NAs and highly correlated variables.
Data x is the training data, y is the variable "classe" in the train data. after removing highly correlated variables of x, 20 has been eliminated, which contains 32 numeric and no NAs variables.
Data y are factor "A"~"E".
elastic_model<-train(y=y,x=x,method="glmnet",trControl = trainControl("cv", number = 10),tuneLength=10)
above model got:
elastic_model$bestTune
alpha lambda
1 0.1 0.01217372
coef(elastic_model$finalModel,s=elastic_model$bestTune$lambda)
Above may give the results of all A~E classes, I can see some variables may be removed.
but below prediction give wrong results:
predictions <- predict(elastic_model,testData)
table(predictions,testData$classe)
predictions A B C D E
A 108 47 19 16 37
B 12 82 0 25 41
C 1121 606 758 233 472
D 433 404 249 690 532
E 0 0 0 0 0
in the predictions, class E is lost totally. I can't find the reason.
r machine-learning classification r-caret
add a comment |
In the cousera.org Machine Learning course assignment project, I adopt elastic net model to find the best classification model.
The training and testing data are compared to find what should be kept as training. I have checked NAs and highly correlated variables.
Data x is the training data, y is the variable "classe" in the train data. after removing highly correlated variables of x, 20 has been eliminated, which contains 32 numeric and no NAs variables.
Data y are factor "A"~"E".
elastic_model<-train(y=y,x=x,method="glmnet",trControl = trainControl("cv", number = 10),tuneLength=10)
above model got:
elastic_model$bestTune
alpha lambda
1 0.1 0.01217372
coef(elastic_model$finalModel,s=elastic_model$bestTune$lambda)
Above may give the results of all A~E classes, I can see some variables may be removed.
but below prediction give wrong results:
predictions <- predict(elastic_model,testData)
table(predictions,testData$classe)
predictions A B C D E
A 108 47 19 16 37
B 12 82 0 25 41
C 1121 606 758 233 472
D 433 404 249 690 532
E 0 0 0 0 0
in the predictions, class E is lost totally. I can't find the reason.
r machine-learning classification r-caret
Please provide some sample data to work with. You can usedput
for data.
– NelsonGon
Mar 9 at 4:57
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24
add a comment |
In the cousera.org Machine Learning course assignment project, I adopt elastic net model to find the best classification model.
The training and testing data are compared to find what should be kept as training. I have checked NAs and highly correlated variables.
Data x is the training data, y is the variable "classe" in the train data. after removing highly correlated variables of x, 20 has been eliminated, which contains 32 numeric and no NAs variables.
Data y are factor "A"~"E".
elastic_model<-train(y=y,x=x,method="glmnet",trControl = trainControl("cv", number = 10),tuneLength=10)
above model got:
elastic_model$bestTune
alpha lambda
1 0.1 0.01217372
coef(elastic_model$finalModel,s=elastic_model$bestTune$lambda)
Above may give the results of all A~E classes, I can see some variables may be removed.
but below prediction give wrong results:
predictions <- predict(elastic_model,testData)
table(predictions,testData$classe)
predictions A B C D E
A 108 47 19 16 37
B 12 82 0 25 41
C 1121 606 758 233 472
D 433 404 249 690 532
E 0 0 0 0 0
in the predictions, class E is lost totally. I can't find the reason.
r machine-learning classification r-caret
In the cousera.org Machine Learning course assignment project, I adopt elastic net model to find the best classification model.
The training and testing data are compared to find what should be kept as training. I have checked NAs and highly correlated variables.
Data x is the training data, y is the variable "classe" in the train data. after removing highly correlated variables of x, 20 has been eliminated, which contains 32 numeric and no NAs variables.
Data y are factor "A"~"E".
elastic_model<-train(y=y,x=x,method="glmnet",trControl = trainControl("cv", number = 10),tuneLength=10)
above model got:
elastic_model$bestTune
alpha lambda
1 0.1 0.01217372
coef(elastic_model$finalModel,s=elastic_model$bestTune$lambda)
Above may give the results of all A~E classes, I can see some variables may be removed.
but below prediction give wrong results:
predictions <- predict(elastic_model,testData)
table(predictions,testData$classe)
predictions A B C D E
A 108 47 19 16 37
B 12 82 0 25 41
C 1121 606 758 233 472
D 433 404 249 690 532
E 0 0 0 0 0
in the predictions, class E is lost totally. I can't find the reason.
r machine-learning classification r-caret
r machine-learning classification r-caret
edited Mar 9 at 4:55
NelsonGon
3,6594834
3,6594834
asked Mar 9 at 3:55
lovegirllovegirl
11
11
Please provide some sample data to work with. You can usedput
for data.
– NelsonGon
Mar 9 at 4:57
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24
add a comment |
Please provide some sample data to work with. You can usedput
for data.
– NelsonGon
Mar 9 at 4:57
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24
Please provide some sample data to work with. You can use
dput
for data.– NelsonGon
Mar 9 at 4:57
Please provide some sample data to work with. You can use
dput
for data.– NelsonGon
Mar 9 at 4:57
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073825%2fin-r-elastic-net-missing-class-in-classification-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073825%2fin-r-elastic-net-missing-class-in-classification-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please provide some sample data to work with. You can use
dput
for data.– NelsonGon
Mar 9 at 4:57
Thank you! I have solved the problem by scaling the data.
– lovegirl
Mar 12 at 5:24