predict-methods: predict method for fit objects (rminer)

Description Arguments Details Value Methods References See Also Examples

Description

predict method for fit objects (rminer)

Arguments

object

a model object created by fit

newdata

a data frame or matrix containing new data

Details

Returns predictions for a fit model. Note: the ... optional argument is currently only used by cubist model (see example).

Value

If task is prob returns a matrix, where each column is the class probability.
If task is class returns a factor.
If task is reg returns a numeric vector.

Methods

signature(object = "model")

describe this method here

References

See Also

fit, mining, mgraph, mmetric, savemining, CasesSeries, lforecast and Importance.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
### simple classification example with logistic regression
data(iris)
M=fit(Species~.,iris,model="lr")
P=predict(M,iris)
print(mmetric(iris$Species,P,"CONF")) # confusion matrix

### simple regression example
data(sa_ssin)
H=holdout(sa_ssin$y,ratio=0.5,seed=12345)
Y=sa_ssin[H$ts,]$y # desired test set
# fit multiple regression on training data (half of samples)
M=fit(y~.,sa_ssin[H$tr,],model="mr") # multiple regression
P1=predict(M,sa_ssin[H$ts,]) # predictions on test set
print(mmetric(Y,P1,"MAE")) # mean absolute error

### fit cubist model
M=fit(y~.,sa_ssin[H$tr,],model="cubist") #
P2=predict(M,sa_ssin[H$ts,],neighbors=3) #
print(mmetric(Y,P2,"MAE")) # mean absolute error
P3=predict(M,sa_ssin[H$ts,],neighbors=7) #
print(mmetric(Y,P3,"MAE")) # mean absolute error

### check fit for more examples

Example output

$res
NULL

$conf
            pred
target       setosa versicolor virginica
  setosa         50          0         0
  versicolor      0         49         1
  virginica       0          1        49

$roc
NULL

$lift
NULL

[1] 0.03069585
[1] 0.003472095
[1] 0.003580136
Warning message:
system call failed: Cannot allocate memory 

rminer documentation built on May 1, 2019, 7:48 p.m.