Polynomial Networks and Factorization Machines: New Insights and Efficient Training Algorithms
Mathieu Blondel, Masakazu Ishihata, Akinori Fujino, Naonori Ueda
Introduction
Interactions between features play an important role in many classification and regression tasks. One of the simplest approach to leverage such interactions consists in explicitly augmenting feature vectors with products of features (monomials), as in polynomial regression. Although fast linear model solvers can be used (Chang et al., 2010; Sonnenburg & Franc, 2010), an obvious drawback of this kind of approach is that the number of parameters to estimate scales as , where is the number of features and is the order of interactions considered. As a result, it is usually limited to second or third-order interactions.
Another popular approach consists in using a polynomial kernel so as to implicitly map the data via the kernel trick. The main advantage of this approach is that the number of parameters to estimate in the model is actually independent of and . However, the cost of storing and evaluating the model is now proportional to the number of training instances. This is sometimes called the curse of kernelization (Wang et al., 2010). Common ways to address the issue include the Nyström method (Williams & Seeger, 2001), random features (Kar & Karnick, 2012) and sketching (Pham & Pagh, 2013; Avron et al., 2014).
Related work
2 Factorization machines
One of the simplest way to leverage feature interactions is polynomial regression (PR). For example, for second-order interactions, in this approach, we compute predictions by
Polynomial and ANOVA kernels
In this section, we show that the prediction functions used by polynomial networks and factorization machines can be written using (1) for a specific choice of kernel.
The polynomial kernel is a popular kernel for using combinations of features. The kernel is defined as
We thus see that uses all monomials of degree (i.e., all combinations of features with replacement).
A much lesser known kernel is the ANOVA kernel (Stitson et al., 1997; Vapnik, 1998). Following (Shawe-Taylor & Cristianini, 2004, Section 9.2), the ANOVA kernel of degree , where , can be defined as
As a result, uses only monomials composed of distinct features (i.e., feature combinations without replacement). For later convenience, we also define and .
With and defined, we are now in position to state the following lemma.
Let be defined as in (1). Then,
The relation easily extends to higher orders. This new view allows us to state results that will be very useful in the next sections. The first one is that and are homogeneous functions, i.e., they satisfy
Another key property of is multi-linearity.A function is called multi-linear (resp. multi-convex) if it is linear (resp. convex) w.r.t. separately.
Multi-linearity of w.r.t.
where denotes the -dimensional vector with removed and similarly for .
That is, everything else kept fixed, is an affine function of , . Proof is given in Appendix B.1.
Assuming is dense and sparse, the cost of naively computing by (8) is , where is the number of non-zero features in . To address this issue, we will make use of the following lemma for computing in nearly time when .
where we defined and .
Direct approach
Multi-convexity of (14) when
is convex in and in each row of separately.
Proof is given in Appendix B.3. As a corollary, the objective function of FMs of arbitrary order is thus multi-convex. Theorem 1 suggests that we can minimize (14) efficiently when by solving a succession of convex problems w.r.t. and the rows of . We next show that when is odd, we can just fix without loss of generality.
When is it useful to fit ?
Let . Then
The result stems from the fact that and are homogeneous functions. If we define , then we obtain if is odd, and similarly for . That is, can be absorbed into without loss of generality. When is even, cannot be absorbed unless we allow complex numbers. Because FMs fix , Lemma 4 shows that the class of functions that FMs can represent is possibly smaller than our framework.
Lifted approach
We begin by rewriting the kernel definitions using rank-one tensors. For , it is easy to see that
For , we need to ignore irrelevant monomials. For convenience, we introduce the following notation:
We can now concisely rewrite the ANOVA kernel as
Our key insight is described in the following lemma.
Link between tensors and kernel expansions
If is decomposed as in (20), then from Lemma 5, we obtain for or . This suggests that we can convert the problem of learning and to that of learning a symmetric tensor of (symmetric) rank . Thus, the problem of finding a small number of bases and their associated weights is converted to that of learning a low-rank symmetric tensor. Following (Candès et al., 2013), we call this approach lifted. Intuitively, we can think of as a tensor that contains the weights for predicting of monomials of degree . For instance, when , is the weight corresponding to the monomial .
2 Multi-convex formulation
Due to multi-linearity of (25) w.r.t. , the objective function is multi-convex in .
Computing predictions efficiently. When , predictions are computed by . To compute them efficiently, we use the following lemma.
Symmetrization does not affect inner product
As a result, we never need to explicitly compute the symmetrized tensor. For the case , cf. Appendix D.3.
Regularization
In some applications, the number of bases or the rank constraint are not enough for obtaining good generalization performance and it is necessary to consider additional form of regularization. For the lifted objective with or , we use the typical Frobenius-norm regularization
where is a regularization hyper-parameter. For the direct objective, we introduce the new regularization
This allows us to regularize and with a single hyper-parameter. Let us define the following nuclear norm penalized objective:
We can show that (28), (29) and (30) are equivalent in the following sense.
Let or , then
Coordinate descent algorithms
Let us denote the elements of by . Then, our algorithm cyclically performs the following update for all and :
The key challenge to use CD is computing efficiently. Let us denote the elements of by . Using Lemma 3, we obtain and . If for all and for fixed, we maintain and (i.e., keep in sync after every update of ), then computing takes time. Hence the cost of one epoch, i.e. updating all elements of once, is . Complete details and pseudo code are given in Appendix D.1.
where . The main difficulty is computing efficiently. If for all and for and fixed, we maintain , then the cost of computing is . Hence the cost of one epoch is , the same as SGD. Complete details are given in Appendix D.2.
Convergence. The above updates decrease the objective monotonically. Convergence to a stationary point is guaranteed following (Bertsekas, 1999, Proposition 2.7.1).
Inhomogeneous polynomial models
The algorithms presented so far are designed for homogeneous polynomial kernels and . These kernels only use monomials of the same degree . However, in many applications, we would like to use monomials of up to some degree. In this section, we propose a simple idea to do so using the algorithms presented so far, unmodified. Our key observation is that we can easily turn homogeneous polynomials into inhomogeneous ones by augmenting the dimensions of the training data with dummy features.
Next, we explain how to learn inhomogeneous polynomial models using . Using Lemma 2, we immediately obtain for :
Experimental results
As explained in Section 4, there is no benefit to fitting when is odd, since and can absorb into . This is however not the case when is even: and can absorb absolute values but not negative signs (unless complex numbers are allowed for parameters). Therefore, when is even, the class of functions we can represent with models of the form (1) is possibly smaller if we fix (as done in FMs).
To check that this is indeed the case, on the diabetes dataset, we minimized (29) with as follows:
minimize w.r.t. both and alternatingly,
fix for and minimize w.r.t. ,
fix with proba. and minimize w.r.t. .
We initialized elements of by for all , . Our results are shown in Figure 1. For , we use CD and for , we use L-BFGS. Note that since (29) is convex w.r.t. , a) is insensitive to the initialization of as long as we fit before . Not surprisingly, fitting allows us to achieve a smaller objective value. This is especially apparent when . However, the difference is much smaller when . We give intuitions as to why this is the case in Section 10.
We emphasize that this experiment was designed to confirm that fitting does indeed improve representation power of the model when is even. In practice, it is possible that fixing reduces overfitting and thus improves generalization error. However, this highly depends on the data.
2 Direct vs. lifted optimization
3 Recommender system experiment
To confirm the ability of the proposed framework to infer the weights of unobserved feature interactions, we conducted experiments on Last.fm and Movielens 1M, two standard recommender system datasets. Following (Rendle, 2012), matrix factorization can be reduced to FMs by creating a dataset of pairs where contains the one-hot encoding of the user and item and is the corresponding rating (i.e., number of training instances equals number of ratings). We compared four models:
(linear combination): ,
(linear combination): ,
4 Low-budget non-linear regression experiment
In this experiment, we demonstrate the ability of the proposed framework to reach good regression performance with a small number of bases . We compared:
Proposed with (with augmented features),
Proposed with (with augmented features),
Nyström method with and
Random Selection: choose uniformly at random from training set and use .
For a) and b) we used the lifted approach. For fair comparison in terms of model size (number of floats used), we set . Results on the abalone, cadata and cpusmall datasets are shown in Figure 4. We see that i) the proposed framework reaches the same performance as kernel ridge regression with much fewer bases than other methods and ii) tends to outperform on these tasks. Similar trends were observed when using or .
Discussion
Ability to infer weights of unobserved interactions. In our view, one of the strengths of PNs and FMs is their ability to infer the weights of unobserved feature interactions, unlike traditional kernel methods. To see why, recall that in kernel methods, predictions are computed by . When or , by Lemma 5, this is equivalent to or if we set . Thus, in kernel methods, the weight associated with can be written as a linear combination of the training data’s monomials:
Assuming binary features, the weights of monomials that were never observed in the training set are zero. In contrast, in PNs and FMs, we have and therefore the weight associated with becomes
Because parameters are shared across monomials, PNs and FMs are able to interpolate the weights of monomials that were never observed in the training set. This is the key property which makes it possible to use them on recommender system tasks. In future work, we plan to apply PNs and FMs to biological data, where this property should be very useful, e.g., for inferring higher-order interactions between genes.
and therefore the model is unable to predict negative values.
Empirically, we showed in Section 9.4 that outperforms for low-budget non-linear regression. In contrast, we showed in Section 9.3 that outperforms for recommender systems. The main difference between the two experiments is the nature of the features used: continuous for the former and binary for the latter. For binary features, squared features are redundant with and are therefore not expected to help improve accuracy. On the contrary, they might introduce bias towards first-order features. We hypothesize that the ANOVA kernel is in general a better choice for binary features, although this needs to be verified by more experiments, for instance on natural language processing (NLP) tasks.
Conclusion
In this paper, we revisited polynomial networks (Livni et al., 2014) and factorization machines (Rendle, 2010, 2012) from a unified perspective. We proposed direct and lifted optimization approaches and showed their equivalence in the regularized case for . With respect to PNs, we proposed the first CD solver with support for arbitrary integer . With respect to FMs, we made several novel contributions including making a connection with the ANOVA kernel, proving important properties of the objective function and deriving the first CD solver for third-order FMs. Empirically, we showed that the proposed algorithms achieve excellent performance on non-linear regression and recommender system tasks.
Acknowledgments
This work was partially conducted as part of “Research and Development on Fundamental and Applied Technologies for Social Big Data”, commissioned by the National Institute of Information and Communications Technology (NICT), Japan. We also thank Vlad Niculae, Olivier Grisel, Fabian Pedregosa and Joseph Salmon for their valuable comments.
References
Appendix A Symmetric tensors
In other words is a copy of with its axes permuted. This generalizes the concept of transpose to tensors.
where is called the symmetric rank of . This generalizes the concept of eigendecomposition to tensors. These two concepts are illustrated in Figure 5.
A.2 Proof of Lemma 26
Appendix B Proofs related to ANOVA kernels
where we used .
For , first notice that we can rewrite (8) as
We can always permute the elements of and without changing . It follows that
B.2 Efficient computation when m∈{2,3}𝑚23m\in\{2,3\}
Using the multinomial theorem, we can expand the homogeneous polynomial kernel as
To simplify notation, we define the shorthands
For , the possible monomials are of the form for all and for . Applying (60), we obtain
This formula was already mentioned in (Stitson et al., 1997). It was also rediscovered in (Rendle, 2010, 2012), although the connection with the ANOVA kernel was not identified.
For , the possible monomials are of the form for all , for and for . Applying (60), we obtain
We can compute the second term efficiently by using
B.3 Proof of multi-convexity (Theorem 1)
Hence is an affine function of . The composition of a convex loss function and an affine function is convex. Therefore, (14) is convex in . Convexity w.r.t. is obvious.
Appendix C Proof of equivalence between regularized problems (Theorem 2)
First, we are going to prove that the optimal solution of the nuclear norm penalized problem is a symmetric matrix. For that, we need the following lemma.
Upper-bound on nuclear norm of symmetrized matrix
Symmetry of optimal solution of nuclear norm penalized problem
Next, we recall the variational formulation of the nuclear norm based on the SVD.
Variational formulation of nuclear norm based on SVD
For a proof, see for instance (Mazumder et al., 2010, Section A.5).
Now, we give a specialization of the above for symmetric matrices, based on the eigendecomposition instead of SVD.
Variational formulation of nuclear norm based on eigendecomposition
Now, computing gives . The minimum value follows from the fact that is orthonormal and hence .
We now have all the tools to prove our result. The equivalence between (28) and (30) when is a special case of (Mazumder et al., 2010, Theorem 3). From Lemma 74, we know that the optimal solution of (30) is symmetric. This allows us to substitute (75) with (76), and therefore, (29) is equivalent to (30) with . As discussed in (Mazumder et al., 2010), the result also holds when is larger than .
Appendix D Efficient coordinate descent algorithms
The fact that the second derivative is null is a consequence of the multi-linearity of .
For an efficient implementation, we need to maintain and statistics that depend on . For the former, we need memory. For the latter, we need memory for an implementation with full cache. However, this requirement is not realistic for a large training set. In practice, the memory requirement can be reduced to if we recompute the quantities then sweep through for fixed. Overall the cost of one epoch is . A similar implementation technique is described for factorization machines with in (Rendle, 2012).
The first and second coordinate-wise derivatives are given by
We consider the following regularized objective function
For an efficient implementation, the two quantities we need to maintain are and . For the former, we need memory. For the latter, we need memory for an implementation with full cache. However, this requirement is not realistic for a large training set. In practice, the memory requirement can be reduced to if we recompute the quantity then sweep through for and fixed. Overall the cost of one epoch is .
For , efficient computations are more involved since we need to ignore irrelevant monomials. Nevertheless, we can also compute the predictions directly without explicitly symmetrizing the model. For , it suffices to subtract the effect of squared features. It is easy to verify that we then obtain
where indicates element-wise product. The coordinate-wise derivatives are given by
Generalizing this to arbitrary is a future work.
Appendix E Datasets
For regression experiments, we used the following public datasets.
The diabetes dataset is available in scikit-learn (Pedregosa et al., 2011). Other datasets are available from http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/.
For recommender system experiments, we used the following two public datasets.
The design matrix was constructed following (Rendle, 2010, 2012). Namely, for each rating , the corresponding is set to the concatenation of the one-hot encodings of the user and item indices. Hence the number of samples is the number of ratings and the number of features is equal to the sum of the number of users and items. Each sample contains exactly two non-zero features. It is known that factorization machines are equivalent to matrix factorization when using this representation (Rendle, 2010, 2012).
We split samples uniformly at random between 75% for training and 25% for testing.