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

better clarify how to do prediction in documentation #92

Open
dustinvtran opened this issue Jan 16, 2017 · 1 comment
Open

better clarify how to do prediction in documentation #92

dustinvtran opened this issue Jan 16, 2017 · 1 comment

Comments

@dustinvtran
Copy link
Member

from an e-mail exchange with @drizzersilverberg:

  1. Can 'sgd' package perform linear regression task to build a model and predict a set of data using the built model?

  2. If so, can you show me the way (code/script) to build the model and predict simple data? as an example, you can use this house_price data.

  3. Last, can 'sgd' compute the prediction error using mean-square-error/root-mean-square-error? If > so, can you show me the way (code/script) to use it in above example?

my reply:

  1. the main function sgd will estimate parameters for a chosen model such as linear regression. there are utility functions to handle the tasks post-estimation. for example, the predict function takes the output of sgd and test covariates/features as input; the output is the predicted response. (see ?predict.sgd)

  2. following the example on the README.md (https://github.com/airoldilab/sgd/blob/master/NAMESPACE), you can do something like:

X_test <- matrix(rnorm(50*d), ncol=d)
y_hat <- predict(sgd.theta, cbind(X_test, 1))

  1. to get the numerical values, you have to do it manually; for example, we have a demo for mean-squared error over the parameters (see ?sgd):

sprintf("Mean squared error: %0.3f", mean((theta - as.numeric(sgd.theta$coefficients))^2))

however, we also have plots that can do MSE or classification error in predictions. (see ?plot) including the numerical output would be as simple as exposing the utility functions we wrote there; we chose not to in order to force the user to not rely on helper functions.

i think these could be made more explicit in the documentation.

@kwajiehao
Copy link

kwajiehao commented Nov 18, 2017

just a note, when I tried to use predict with sgd, i get an error

Error in x_test %*% object$coefficients :
requires numeric/complex matrix/vector arguments

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