Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the predictions for each gene? #10

Open
dgarrimar opened this issue Oct 6, 2022 · 9 comments
Open

How to get the predictions for each gene? #10

dgarrimar opened this issue Oct 6, 2022 · 9 comments

Comments

@dgarrimar
Copy link

Hi,

I ran the pipeline on my data smoothly, and got the ROC AUC in the train and test sets. However, I am not very familiar with torch/lua. How could I obtain the final predictions for each gene in the test set (either the 0/1 label or better the probablity [0,1])?. I guess this means just adding/modifying a couple of lines of code.

thanks!

PS. I'd be great too if I could obtain the accuracy/confusion matrices for the test set (not only the ROC AUC)

@jacklanchantin
Copy link
Collaborator

The unnormalized outputs will be in the output variable here

You can append a nn.SoftMax module to the model in order to get normalized probabilities.

btw - have you tried the AttentiveChrome pytorch code in the repository? It's likely much easier to follow.

@dgarrimar
Copy link
Author

I am still not sure on how to do this in lua, you mean something like: local ex = nn.SoftMax(output) and then print ex to a file? I am not familiar with lua objects. Which kind of object is output ? It seems it is not just a number. The same for ex. Could you please give me some more hints on how to store the actual numbers in a file? Thanks a lot! I also had a look at the pytorch code, but it seems to be much slower on the same dataset (I am using CPUs for now).

@jacklanchantin
Copy link
Collaborator

you can do normalized_output = nn.SoftMax()(output)

output is a torch tensor
normalized_output[:,0] = p(x=true)
normalized_output[:,1] = p(x=false)

you can write each of these to a csv file using standard lua write to file methods.

@dgarrimar
Copy link
Author

Uhm, for some reason it complains: unexpected symbol near ':'. (I just copy/pasted)

@jacklanchantin
Copy link
Collaborator

I don't remember what dimension normalized_output would be. Can you try removing the :, ?

@dgarrimar
Copy link
Author

same :( (')' expected near '=')

@jacklanchantin
Copy link
Collaborator

oh you shouldn't use = p(x=true), i was explaining what those will give you - i.e. the probability that the input is has expression=true

@dgarrimar
Copy link
Author

I see haha, but still normalized_output:nDimension() is 1

@dgarrimar
Copy link
Author

OK I think I got it :), normalized_output[1] should give the probability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants