050-predict.FMmodel: Predict Method for FMmodel Objects

Description Usage Arguments See Also Examples

Description

Function for predicting new data based on a FMmodel object

Usage

1
2
   ## S3 method for class 'FMmodel'
predict(object, newdata, truncate = T, ...)

Arguments

object

a FMmodel object (output of SVM.train, FM.train, or HoFM.train)

newdata

new data for prediction based on the FMmodel object (number of features must match the features of the training data)

truncate

bool indicating whether the output should be trunceted (T) order not (F)

...

additional arguments

See Also

SVM.train, FM.train, HoFM.train

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
### Example to illustrate the usage of the method
### Data set very small and not sparse, results not representative
### Please study major example in general help 'FactoRizationMachines'

# Load data set
library(FactoRizationMachines)
library(MASS)
data("Boston")

# Subset data to training and test data
set.seed(123)
subset=sample.int(nrow(Boston),nrow(trees)*.8)
data.train=Boston[subset,-ncol(Boston)]
target.train=Boston[subset,ncol(Boston)]
data.test=Boston[-subset,-ncol(Boston)]
target.test=Boston[-subset,ncol(Boston)]


# Predict with 10 second-order and 5 third-order factor
model=HoFM.train(data.train,target.train)

# RMSE resulting from test data prediction
sqrt(mean((predict(model,data.test)-target.test)^2))

FactoRizationMachines documentation built on Nov. 17, 2017, 4:21 a.m.