Description Usage Arguments Value See Also Examples
Similar to other predict
methods, this function predicts fitted values
or coefficients from a fitted "droplasso
" object
1 2 3 |
object |
Fitted " |
newx |
Matrix of new values for |
s |
Value(s) of the penalty parameter lambda at which predictions are
required. Can be either omitted, or a vector of numeric values. If omitted
(or equal to |
type |
Type of prediction required. Type |
... |
Other parameters. |
If type="link"
, returns a matrix of prediction scores, one row
per sample of newx
, one column per value of lambda. If
type="coefficients"
, returns a matrix of weights of the model, one
row per feature, one column per value of lambda.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #create data:
nobs = 100
nvars = 5
x = matrix(rnorm(nobs*nvars),nrow=nobs)
b = c(1,1,0,0,0)
p = 1/(1+exp(-x%*%b))
y = p>0.5
# Fit a dropout lasso model
m <- droplasso(x, y, family="binomial", nlambda=50, decay=5)
# Plot is
plot(m)
# Plot the weights for lambda=0.01
plot(predict(m,s=0.01), xlab="Features", ylab="Weight", main="Lambda=0.01")
# Plot prediction score
plot(predict(m, x, s=0.01), xlab="Sample", ylab="Score", main="Lambda=0.01")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.