030-FM.train: Method training a second-order Factorization Machine

Description Usage Arguments References See Also Examples

Description

FM.train is a method training a second-order Factorization Machine.

factors specifies the model parameters of the Factorization Machine: the first element specifies whether linear weights are used (1) or not (0), the second element specifies the number of parameters factorizing the second-order.

Usage

1
2
  FM.train(data, target, factors = c(1, 10), intercept = T, 
  iter = 100, regular = NULL, stdev = 0.1)

Arguments

data

an object of class dgTMatrix, matrix or data.frame (or an object coercible to dgTMatrix): a matrix containing training data, each row representing a training example and each column representing a feature.

target

numeric: vector specifying the target value of each training example (length must match rows of object data).

factors

numeric: vector specifying the number of factors for each considered order: the first element specifies whether linear weights are used (1) or not (0), the second element specifies the number of parameters factorizing the second-order.

intercept

logical: specifying whether a global intercept is used (TRUE) or not (FALSE).

iter

integer: the number of iterations the learning method is applied.

regular

numeric: regularization value for each order corresponding to factors. If one value, each order is regularized with this value, otherwise the first element of the vector specifies the regularization value for the linear weights and the second the regularization value for the second-order factors. If regular is NULL, automatic regularization using Markov Chain Monte Carlo (MCMC) method is applied.

stdev

numeric: the standard deviation used to initialize the model parameters.

References

[1] J. Knoll, Recommending with Higer-Order Factorization Machines, Research and Development in Intelligent Systems XXXIII, 2016.

[2] S. Rendle, Factorization Machines with libFM, ACM Transactions onIntelligent Systems and Technology (TIST), 3, 2012.

See Also

FactoRizationMachines

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## Not run: 

### 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 3 second-order factors with MCMC regularization
model=FM.train(data.train,target.train,c(1,3))

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


# Predict with 10 second-order factor with MCMC regularization
model=FM.train(data.train,target.train)

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


# Predict with 10 second-order factor with manual regularization
model=FM.train(data.train,target.train,regular=0.1)

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


## End(Not run)

Example output

[1] 23.29936
[1] 26.3729
[1] 23.55606

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