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;








0















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.










share|improve this question
























  • 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

















0















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.










share|improve this question
























  • 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













0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















  • 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
















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












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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme