Incorporating multiple categories to understand relationships between them in a sequential modelBinary classification with Keras: poor performanceHow to study the effect of each data on a deep neural network model?Variable Input Shape for Keras Sequential ModelCan I perform Keras training in a deterministic manner?loss, val_loss, acc and val_acc do not update at all over epochsKeras : Why does Sequential and Model give different outputs?Same model produces consistently different accuracies in Keras and Tensorflowpreparing data with 6 time points in a sequential model: Keras for R'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model

How to be sure services and researches offered by the University are not becoming cases of unfair competition?

What was the motivation for the invention of electric pianos?

Is using gradient descent for MIP a good idea?

Can you add polynomial terms to multiple linear regression?

How can I discourage sharing internal API keys within a company?

What is the mathematical notation for rounding a given number to the nearest integer?

Are there any “Third Order” acronyms used in space exploration?

Why is my fire extinguisher emptied after one use?

Does deswegen have another meaning than "that is why"?

What officially disallows US presidents from driving?

How to publish superseding results without creating enemies

What made 4/4 time the most common time signature?

Why did they ever make smaller than full-frame sensors?

The Planck constant for mathematicians

Can I be reached on FaceTime on Mac using my non-iPhone phone number?

How To Make Earth's Oceans as Brackish as Lyr's

Why the car dealer is insisting on loan instead of cash

Specific filter on the set using Python

Does my opponent need to prove his creature has morph?

How would you control supersoldiers in a late iron-age society?

Why don't Wizards use wrist straps to protect against disarming charms?

How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?

Does a succubus' charm end when it dies?

What explanation do proponents of a Scotland-NI bridge give for it breaking Brexit impasse?



Incorporating multiple categories to understand relationships between them in a sequential model


Binary classification with Keras: poor performanceHow to study the effect of each data on a deep neural network model?Variable Input Shape for Keras Sequential ModelCan I perform Keras training in a deterministic manner?loss, val_loss, acc and val_acc do not update at all over epochsKeras : Why does Sequential and Model give different outputs?Same model produces consistently different accuracies in Keras and Tensorflowpreparing data with 6 time points in a sequential model: Keras for R'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have successfully built a a sequential model to stratify different organs of some genomic data that I have, and this works really well and with a high accuracy too. However, this is also time series data and I would like to understand relationships between different variables in the data and I would like to incorporate these to see what genes drive different relationships over time. I am not sure therefore that this becomes a classification or regression problem at this point. The code for the model is below:



The code to generate the multi-class classification is as follows:



Normcountsonehot <- data.frame(to_categorical(Normcountsall$Age, 
7), to_categorical(Normcountsall$Organ, 13),
to_categorical(Normcountsall$Sex, 4), Normcountsall[,1:5078])


The resulting matrix is time points as rows and genes as columns. Genes contain the values we would like to extract information from.



ind <- sample(2, nrow(Normcountsonehot), replace=TRUE, prob = 
c(0.7,0.3))

training <- Normcountsonehot[ind==1, 25:5098] # includes all
independent variables
test <- Normcountsonehot[ind==2, 25:5098]

*scale test and training*

trainingtarget <- Normcountsonehot[ind==1, c(8:20)]
testtarget <- Normcountsonehot[ind==2, c(8:20)]


The above splits the one-hot encoded data into the organs variable only (and not any of the others (sex, Age)



Sequential model is then:

model1 <- keras_model_sequential()
model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 5074)
%>%
layer_dropout(0.4)%>%
layer_dense(units = 64, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units=13, activation = "softmax")

model1 %>% keras::compile(loss='categorical_crossentropy',
optimizer='adam',
metrics='accuracy')
history1 <- model1%>%
fit(as.matrix(training1), # input, the first independent variables
as.matrix(trainingtarget), # input, Metadata
epoch=20,
batch=32,
validation_split = 0.2)

model1%>%
keras::evaluate(test1,as.matrix(testtarget))


confusion matrix etc...



This classifies just one variable very nicely



If I now add this line of code to include variables such Age and Sex:



trainingtarget <- Normcountsonehot[ind==1, c(1:24)]


and change the input in the model to:



model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 7+13+4
5078) %>% ....
*last layer* layer_dense(units=7+13+4, activation = "softmax")


The train accuracy falls to basically 0 and Val-acc is constantly 0.



While I am trying to understand the relationships between these different variables to then find weights that drive these relationships, I am not sure that this is now classification problem (or the input is completely wrong). Should I remove softmax to make it a regression problem. If so, what is my last layer unit number? and what will it be training on:



again the objective would be to understand the relationships between all of the variables and see if genes change according to this. One of the variables which I have not mentioned is dependent on the type of organs.. and therefore I would like to see how the weights change when the algorithm is specifically looking for these patterns with all variables in mind. i.e... some genes may go down over time because organs x,y and z have a certain property defined by the variable, while these may be completely unchanged in other organs because they do not possess such properties ... Its this kind of pattern recognition I am interested in.



Any help about how to edit the code above to address this question would be much appreciated!! Also note, I will be trying different models too, but just starting with a sequential!



Thank you!










share|improve this question


























  • This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

    – Stefan Dragnev
    Mar 28 at 12:00











  • Thank you! Will post there too!

    – user9317212
    Mar 28 at 12:04

















0















I have successfully built a a sequential model to stratify different organs of some genomic data that I have, and this works really well and with a high accuracy too. However, this is also time series data and I would like to understand relationships between different variables in the data and I would like to incorporate these to see what genes drive different relationships over time. I am not sure therefore that this becomes a classification or regression problem at this point. The code for the model is below:



The code to generate the multi-class classification is as follows:



Normcountsonehot <- data.frame(to_categorical(Normcountsall$Age, 
7), to_categorical(Normcountsall$Organ, 13),
to_categorical(Normcountsall$Sex, 4), Normcountsall[,1:5078])


The resulting matrix is time points as rows and genes as columns. Genes contain the values we would like to extract information from.



ind <- sample(2, nrow(Normcountsonehot), replace=TRUE, prob = 
c(0.7,0.3))

training <- Normcountsonehot[ind==1, 25:5098] # includes all
independent variables
test <- Normcountsonehot[ind==2, 25:5098]

*scale test and training*

trainingtarget <- Normcountsonehot[ind==1, c(8:20)]
testtarget <- Normcountsonehot[ind==2, c(8:20)]


The above splits the one-hot encoded data into the organs variable only (and not any of the others (sex, Age)



Sequential model is then:

model1 <- keras_model_sequential()
model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 5074)
%>%
layer_dropout(0.4)%>%
layer_dense(units = 64, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units=13, activation = "softmax")

model1 %>% keras::compile(loss='categorical_crossentropy',
optimizer='adam',
metrics='accuracy')
history1 <- model1%>%
fit(as.matrix(training1), # input, the first independent variables
as.matrix(trainingtarget), # input, Metadata
epoch=20,
batch=32,
validation_split = 0.2)

model1%>%
keras::evaluate(test1,as.matrix(testtarget))


confusion matrix etc...



This classifies just one variable very nicely



If I now add this line of code to include variables such Age and Sex:



trainingtarget <- Normcountsonehot[ind==1, c(1:24)]


and change the input in the model to:



model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 7+13+4
5078) %>% ....
*last layer* layer_dense(units=7+13+4, activation = "softmax")


The train accuracy falls to basically 0 and Val-acc is constantly 0.



While I am trying to understand the relationships between these different variables to then find weights that drive these relationships, I am not sure that this is now classification problem (or the input is completely wrong). Should I remove softmax to make it a regression problem. If so, what is my last layer unit number? and what will it be training on:



again the objective would be to understand the relationships between all of the variables and see if genes change according to this. One of the variables which I have not mentioned is dependent on the type of organs.. and therefore I would like to see how the weights change when the algorithm is specifically looking for these patterns with all variables in mind. i.e... some genes may go down over time because organs x,y and z have a certain property defined by the variable, while these may be completely unchanged in other organs because they do not possess such properties ... Its this kind of pattern recognition I am interested in.



Any help about how to edit the code above to address this question would be much appreciated!! Also note, I will be trying different models too, but just starting with a sequential!



Thank you!










share|improve this question


























  • This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

    – Stefan Dragnev
    Mar 28 at 12:00











  • Thank you! Will post there too!

    – user9317212
    Mar 28 at 12:04













0












0








0








I have successfully built a a sequential model to stratify different organs of some genomic data that I have, and this works really well and with a high accuracy too. However, this is also time series data and I would like to understand relationships between different variables in the data and I would like to incorporate these to see what genes drive different relationships over time. I am not sure therefore that this becomes a classification or regression problem at this point. The code for the model is below:



The code to generate the multi-class classification is as follows:



Normcountsonehot <- data.frame(to_categorical(Normcountsall$Age, 
7), to_categorical(Normcountsall$Organ, 13),
to_categorical(Normcountsall$Sex, 4), Normcountsall[,1:5078])


The resulting matrix is time points as rows and genes as columns. Genes contain the values we would like to extract information from.



ind <- sample(2, nrow(Normcountsonehot), replace=TRUE, prob = 
c(0.7,0.3))

training <- Normcountsonehot[ind==1, 25:5098] # includes all
independent variables
test <- Normcountsonehot[ind==2, 25:5098]

*scale test and training*

trainingtarget <- Normcountsonehot[ind==1, c(8:20)]
testtarget <- Normcountsonehot[ind==2, c(8:20)]


The above splits the one-hot encoded data into the organs variable only (and not any of the others (sex, Age)



Sequential model is then:

model1 <- keras_model_sequential()
model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 5074)
%>%
layer_dropout(0.4)%>%
layer_dense(units = 64, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units=13, activation = "softmax")

model1 %>% keras::compile(loss='categorical_crossentropy',
optimizer='adam',
metrics='accuracy')
history1 <- model1%>%
fit(as.matrix(training1), # input, the first independent variables
as.matrix(trainingtarget), # input, Metadata
epoch=20,
batch=32,
validation_split = 0.2)

model1%>%
keras::evaluate(test1,as.matrix(testtarget))


confusion matrix etc...



This classifies just one variable very nicely



If I now add this line of code to include variables such Age and Sex:



trainingtarget <- Normcountsonehot[ind==1, c(1:24)]


and change the input in the model to:



model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 7+13+4
5078) %>% ....
*last layer* layer_dense(units=7+13+4, activation = "softmax")


The train accuracy falls to basically 0 and Val-acc is constantly 0.



While I am trying to understand the relationships between these different variables to then find weights that drive these relationships, I am not sure that this is now classification problem (or the input is completely wrong). Should I remove softmax to make it a regression problem. If so, what is my last layer unit number? and what will it be training on:



again the objective would be to understand the relationships between all of the variables and see if genes change according to this. One of the variables which I have not mentioned is dependent on the type of organs.. and therefore I would like to see how the weights change when the algorithm is specifically looking for these patterns with all variables in mind. i.e... some genes may go down over time because organs x,y and z have a certain property defined by the variable, while these may be completely unchanged in other organs because they do not possess such properties ... Its this kind of pattern recognition I am interested in.



Any help about how to edit the code above to address this question would be much appreciated!! Also note, I will be trying different models too, but just starting with a sequential!



Thank you!










share|improve this question
















I have successfully built a a sequential model to stratify different organs of some genomic data that I have, and this works really well and with a high accuracy too. However, this is also time series data and I would like to understand relationships between different variables in the data and I would like to incorporate these to see what genes drive different relationships over time. I am not sure therefore that this becomes a classification or regression problem at this point. The code for the model is below:



The code to generate the multi-class classification is as follows:



Normcountsonehot <- data.frame(to_categorical(Normcountsall$Age, 
7), to_categorical(Normcountsall$Organ, 13),
to_categorical(Normcountsall$Sex, 4), Normcountsall[,1:5078])


The resulting matrix is time points as rows and genes as columns. Genes contain the values we would like to extract information from.



ind <- sample(2, nrow(Normcountsonehot), replace=TRUE, prob = 
c(0.7,0.3))

training <- Normcountsonehot[ind==1, 25:5098] # includes all
independent variables
test <- Normcountsonehot[ind==2, 25:5098]

*scale test and training*

trainingtarget <- Normcountsonehot[ind==1, c(8:20)]
testtarget <- Normcountsonehot[ind==2, c(8:20)]


The above splits the one-hot encoded data into the organs variable only (and not any of the others (sex, Age)



Sequential model is then:

model1 <- keras_model_sequential()
model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 5074)
%>%
layer_dropout(0.4)%>%
layer_dense(units = 64, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units=13, activation = "softmax")

model1 %>% keras::compile(loss='categorical_crossentropy',
optimizer='adam',
metrics='accuracy')
history1 <- model1%>%
fit(as.matrix(training1), # input, the first independent variables
as.matrix(trainingtarget), # input, Metadata
epoch=20,
batch=32,
validation_split = 0.2)

model1%>%
keras::evaluate(test1,as.matrix(testtarget))


confusion matrix etc...



This classifies just one variable very nicely



If I now add this line of code to include variables such Age and Sex:



trainingtarget <- Normcountsonehot[ind==1, c(1:24)]


and change the input in the model to:



model1 %>%
layer_dense(units=5078, activation = 'relu', input_shape = 7+13+4
5078) %>% ....
*last layer* layer_dense(units=7+13+4, activation = "softmax")


The train accuracy falls to basically 0 and Val-acc is constantly 0.



While I am trying to understand the relationships between these different variables to then find weights that drive these relationships, I am not sure that this is now classification problem (or the input is completely wrong). Should I remove softmax to make it a regression problem. If so, what is my last layer unit number? and what will it be training on:



again the objective would be to understand the relationships between all of the variables and see if genes change according to this. One of the variables which I have not mentioned is dependent on the type of organs.. and therefore I would like to see how the weights change when the algorithm is specifically looking for these patterns with all variables in mind. i.e... some genes may go down over time because organs x,y and z have a certain property defined by the variable, while these may be completely unchanged in other organs because they do not possess such properties ... Its this kind of pattern recognition I am interested in.



Any help about how to edit the code above to address this question would be much appreciated!! Also note, I will be trying different models too, but just starting with a sequential!



Thank you!







keras neural-network






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 11:02









Sreeram TP

4,4434 gold badges17 silver badges47 bronze badges




4,4434 gold badges17 silver badges47 bronze badges










asked Mar 28 at 10:55









user9317212user9317212

371 silver badge6 bronze badges




371 silver badge6 bronze badges















  • This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

    – Stefan Dragnev
    Mar 28 at 12:00











  • Thank you! Will post there too!

    – user9317212
    Mar 28 at 12:04

















  • This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

    – Stefan Dragnev
    Mar 28 at 12:00











  • Thank you! Will post there too!

    – user9317212
    Mar 28 at 12:04
















This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

– Stefan Dragnev
Mar 28 at 12:00





This question will likely get more attention on SO's sister site "Cross-Validated" stats.stackexchange.com

– Stefan Dragnev
Mar 28 at 12:00













Thank you! Will post there too!

– user9317212
Mar 28 at 12:04





Thank you! Will post there too!

– user9317212
Mar 28 at 12:04












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/4.0/"u003ecc by-sa 4.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%2f55395824%2fincorporating-multiple-categories-to-understand-relationships-between-them-in-a%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




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















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%2f55395824%2fincorporating-multiple-categories-to-understand-relationships-between-them-in-a%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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해