A Fast and Better Hybrid Recommender System Based on Spark

,


Introduction
Along with the popularization of the Internet, a sharp increase in the amount of data leads to information overload [1].Thus, recommender systems [2] were proposed to relieve the stress of massive data.To improve recommender systems performance, researchers put forward the weighted hybrid method.Despite performance boost has been brought by the method, there are still several problems affecting performance, including weight setting and computation load.Hence, we implement a weighted hybrid recommender system on Spark.In the system, we design a new method to compute weights, using cluster analysis and user similarity.Besides, the execution time can be reduced by deploying the system on Spark.

Hybrid Recommender Systems
Hybrid recommender systems combine two or more recommendation algorithms to overcome weaknesses of each algorithm.It is generally classified as Switching, Mixed, Feature Combination, Meta-Level, and Weighted [3].
The weighted hybrid technique combines different algorithms with different weights [3].The main idea is that the algorithm with better accuracy has a higher weight.At present, developers always set a weight for an algorithm manually and repeat experiments until achieving superior accuracy.Thus, the method depends on developers' experience to determine accuracy of an algorithm in different datasets.Due to large-scale datasets, sparsity of rating data and the number of algorithms, it's generally hard to obtain appropriate weights.Eventually the improvements of accuracy are poor.
In addition, to improve user experience, the system should return recommendation results efficiently.In other words, it has to quickly locate information which can appeal users in massive data.Thus, execution time is another evaluation standard of performance.However, the weighted hybrid technique needs to execute two or more algorithms and compute hybrid results, it's tough to reduce execution time.
Apart from accuracy and execution time of the system, scalability is also an important consideration.With the increasing of data scale and the algorithm complexity, the system requires more storage space and computing resources.It's difficult to meet the actual demand by only optimizing algorithms.
To address the above-mentioned issues, we design a hybrid recommender system on Spark.In the system, we propose an optimized method to improve accuracy.It computes weights and hybrid results based on cluster analysis and user similarity.Meanwhile, we deploy the system on Spark which is a fast and general engine for large-scale data processing [4] to accelerate the training process and improve scalability.

Work of Paper
The rest of this paper is organized as five sections.Section 2 reviews recommendation algorithms and introduces the Spark.Section 3 describes the design of the optimized method.Section 4 shows how we implement the system on Spark.Section 5 gives experimental results and our analysis.Section 6 presents our conclusions and future work.

Related Work
In this section, we first review and compare recommendation algorithms and recommender systems.Then, we briefly analyze predicting ratings of algorithms.Finally, we introduce the distributed computing platform Spark and compare Hadoop and Spark.

Recommender Systems
Recommendation algorithms are the basis of recommender systems.In this section, we first introduce several representative algorithms.
Collaborative recommendation is almost the most popular algorithm.Based on overlapped ratings, it computes similarities among users.And then, it uses similarities to predict the rating that the current user on an item [5].Tapestry [6], Ringo [7] and GroupLens [8] are typical systems with the algorithm.
Content-based recommendation pays attention to connections between items.It analyses descriptions of items that have been rated by users [9] and calculates similarities between items.The represention of an item's feature and the way to classify a new item are two important sub-problems [9].
Demographic-based recommendation [9] is a simple algorithm.It focuses on types of users that like a certain item.The technique identifies features of users such as age, gender, nationality, education, etc.It measures user similarity by taking those features into consideration.Table 1.shows strengths and weaknesses of each algorithm [5][9].As the simple and effective technique, the weighted hybrid recommender system has been widely used in numerous fields.P-Tango and Pazzani are two typical systems.P-Tango is an online news system.It combines collaborative and content-based recommendation algorithms.The system adjusts weights of algorithms in the process of operation.Until the system obtains the expected accuracy, it determines weights.Pazzani is the other weighted hybrid recommender system.It combines collaborative, content-based and demographic-based recommendation algorithms.The system uses voting to determine recommendation results.

Weight Analysis
As previously described in section 1, we give the formalized representation of the weighted hybrid technique as follows: where j represents the j'th algorithm, it ranges from 1 to n. α j corresponds to the weight of the j'th algorithm.r j ui is the predicting rating of user u on item i by the j'th algorithm.R ui indicates the final hybrid result.From the formula (1), we can recognize that each algorithm just has a certain weight.That means the technique presupposes that predicting ratings of an algorithm are all greater or less than their ratings.However, this condition evaluates to false.Here we give some empirical evidence.We implement the User-based Collaborative Filtering (User-CF) and the Alternating Least Squares (ALS) in Python2.7, and use MovieLens-100K as observed data.In the Table 2, countH is the number of predicting ratings which are greater than real ratings.The countL is less than real ratings and countE is equivalent amounts.From the empirical results, we know that: (1) In these algorithms, there are little predicting ratings that equal to ratings.
(2) A part of predicting ratings are greater than ratings, and another are less than ratings.(3) Only a weight for an algorithm may affect accuracy.Thus, it is essential to optimize weights.

Spark
Spark is a fast and general-purpose cluster computing platforms for large-scale data processing [4] which is developed by UC Berkeley.In the environment of Spark, it includes Spark SQL [10], Spark Streaming [11], Mllib [12], GraphX [13], etc.Based on resilient distributed dataset (RDD) [14], it achieves memorybased computing, fault tolerance and scalability.Currently, Spark is deployed in Amazon, ebay and Yahoo! to process large-scale datasets.
For a hybrid recommender system, performance is affected by data scale, the number of algorithms and the complexity of algorithms.Deploy the system on Spark can mitigate above affects.
(1) In the system, large-scale datasets could be stored in distributed storage.
(2) Algorithms are independent with each other, they are supposed to be performed in parallel.(3) Intermediate values can be cached in memory to decrease execution time.
Therefore, in this paper, we design an optimized hybrid recommender system on Spark.

Design Overview
The empirical evidence from section 2 suggests that accuracy still has chance to be improved.The predicting ratings are higher or lower than corresponding ratings.Thus, we use cluster analysis to obtain more accurate weights.The principle of cluster analysis is that according to the properties of samples, using mathematical methods to determine relationship between samples, and according to the relationship to cluster samples.Based on cluster analysis, we present an optimized method for calculating personalized weights.Now let us discuss the method in detail.

Objective Function.
In this section, we first give explanations of several concepts.In the following statement: 1. Assume that there are n algorithms in the system and j is the j'th algorithm.2. u for user, i for item and (u,i) represents the data item of u and i. 3. R ui is the rating of u on i, r j ui is the predicting rating of u on i which is computed by the j'th algorithm.4. For the j'th algorithm, the error between the rating and the predicting rating is: In order to reduce n j=1 u,i D j ui , similar errors are expected to get same weights.Based on errors, we divide (u,i) into k clusters and design C ui = (c 1 , c 2 , • • • , c k ) to reflect the cluster of (u,i).For the j'th algorithm, α j = (α j1 , α j2 , • • • , α jk ) represents k weights of the algorithm.α j C T ui finally determines the weight for r j ui .
According to our analysis, we define the objective function as formula (2):

Weight Calculation
According to D j ui , the optimized method classifies all (u,i) into k clusters .For each (u,i), it has a vector . The value which corresponds to (u,i)'s cluster is set to 1.For instance, if (u,i) belongs to the cluster 2, C ui = (0, 1, 0, • • • , 0).The weight for r j ui is α j2 which is computed by α j C ui T .Therefore, C could map weights to predicting ratings and achieve multiple weights for an algorithm.Fig. 1 shows the pipeline of the method.
After calculating C, the optimized method requires to compute α j .For the purpose of minimizing the objective function, we make use of the Lagrange theory and minimum theory [15] [16].Based on formula (2), the method constructs the Lagrange function L(α).
For each j, let ∂L ∂(αj Cui T ) = 0. We can get an equation: The equation ( 6) can be represented by matrix: Thus the weight matrix X can be calculated by The optimized method uses ratings which have already stored in the system to compute weights.However, these weights aren't entirely appropriate for a new (u,i).We further introduce user similarity to compute weights.The user similarity is computed by cosine similarity: where sim u,v is the similarity between u and v. N (u) means the number of items that u have rated.N (v) is the same as N (u) .For the (u , I ), the optimized method calculates the hybrid result as: (10) The equation ( 10) is able to filter the interference of non similar weights and get a personalized weight for the (u , I ).According to the design overview, we deploy the hybrid recommender system on Spark.The system contains data storage, prediction, cluster, weight, model fusion and recommendation, totally 6 modules.Fig. 2 shows the architecture of the system.

Modules
Data storage module is the basis of the system.It stores input data, including historical data and ratings.We use HDFS which is a distributed file system to store raw data [17].The pre-processed data are put in the database such as HBase, Redis, Hive, etc [18][19] [20].Topside modules read data from the database.Prediction module is used to compute predicting ratings.It performs recommendation algorithms in parallel.Outputs are predicting ratings.
The cluster module concentrates on errors of (u,i).It exploits k-means to classify (u,i).Output of the module is C. The weight module accepts C to compute weights.With C and α, the module can get a weight for each r j ui .Output of it is α.
The model fusion calculates hbrid results based on predicting ratings, C, α and user similarity.According to these parameters, it determines hybrid results by logistic regression [21].Recommendation is used to recommend items for users.Based on hybrid results, it generates recommendation lists.Besides, it also outputs an evaluation for results.

Discussion
In the hybrid recommender system on Spark, data are translated into RDDs.Because of the characteristics of memory-based computing and parallel operations, RDDs can be processed in parallel to reduce execution time.The read-only and fault tolerance of RDD make the system more reliable.Besides, due to the distributed storage of Spark, the system is able to handle large-scale datasets.It improves scalability of the system.Therefore, deploy the hybrid recommender system on Spark could decrease execution time and further improve scalability.

Evaluation Index
Accuracy.The system accuracy is measured by root mean square error (RMSE) [22].It is defined as: where R ui and r ui is the rating and the hytbrid result that u on i respectively.
|T | denotes the number of r ui .
Execution Time.The execution time includes time of algorithms, clustering, calculating weights and hybrid results.It is measured in minutes.

Experimental Setup
In this experiment, we choose Spark as our platform.All experiments were performed using a local cluster with 7 nodes (1 master and 6 worker nodes): each node has Xeon(R) dual-core 2.53GHz processor and 6GB memory.
Dataset.In Table 3, we list datasets that were used in the experiment.For each dataset, we divide it into 2 training sets and a test set randomly.Algorithms.We implement 3 recommendation algorithms: User-CF, Itembased Collaborative Filtering (Item-CF) and ALS.We perform them in training sets and test sets to compute predicting ratings, weights and hybrid results.
Nodes.We compare execution time of the stand-alone system and the distributed system.For the former, we use the server with Xeon(R) dual-core 2.53GHz processor and 6GB memory.For the latter, we use a local cluster with 7 nodes (1 master and 6 worker nodes): each node has Xeon(R) dual-core 2.53GHz processor and 6GB memory.

Performance Comparision
In this section, we evaluate performance of the hybrid recommender system on Spark, including accuracy and execution time.
Fig. 3 shows impacts of data scales on accuracy.In the experiment, we performe the combination of User-CF and ALS on four MovieLens datasets.In the Fig. 3 sparsity of MovieLens-700K, the hybrid recommender system obtains the best result.Compare with User-CF and ALS, the system improves accuracy of 8.21 Fig. 4 gives the RMSE of different types of datasets.In the experiment, we performe the combination of User-CF and ALS on MovieLens-400K and BookCrossing.The Fig. 4 shows that the hybrid recommender system can improve accuracy of different types of datasets.And there are significant improvements on BookCrossing.The improvements demonstrate that the system is available for sparse datasets.Fig. 5 shows correlations between accuracy and combinations of algorithms.In the experiment, four combinations of algorithms are performed on MovieLens-100K, MovieLens-400K and BookCrossing respectively.In Fig. 5, the hybrid recommender system obtains better accuracy than single algorithm.When accura- cy of single algorithm is favorable, the hybrid recommender system also obtains better accuracy.Fig. 6 compares execution time of stand-alone mode and local cluster mode.The experiment performs the combination of User-CF and ALS on MovieLens-100K to MovieLens-1M.For the stand-alone system, execution time increases sharply with the expansion of data scale.However, execution time of local cluster mode remains relatively constant.When the data scale is larger than MovieLens-900K, the stand-alone mode couldn't handle it.The local cluster mode could handle MovieLens-10M or larger datasets.From Fig. 6, we can recognize that memory-based computing, parallel operations and distributed storage of Spark are helpful to decrease execution time and improve scalability.

Conclusion and Future Work
Improving performance of recommender systems is a crucial solution for information overload.This paper designs a new weighted hybrid recommender system to solve this problem.We are the first to compute weights by using cluster analysis, user similarity and minimum theory.Besides, we deploy the hybrid recommender system on Spark.The system improves accuracy by optimizing weights and reduces execution time by memory-based computing and parallel operations.And distributed storage of the system is helpful to improve scalability.The experiment results demonstrate the performance of our hybrid recommender system.
In future work, we will consider to improve and extend the system: expansion of algorithm to process more complex scenes.Further research on factors influencing weights to improve accuracy.Meanwhile, optimize the implementation of the system on Spark.

Fig. 1 .
Fig.1.The pipeline of the optimized method.The input file consists of ratings.Algorithms read the input file and output predicting ratings.Then the system computes errors and cluster data items.Finally the system gives the C.

Fig. 2 .
Fig.2.The architecture of the hybrid recommender system.The system reads ratings and outptu recommendation lists.Besides, it also provides an evaluation index.

Fig. 5 .
Fig. 5.The RMSE of different combinations of algorithms.The x-axis indicates the dataset, and the y-axis describes the RMSE.

Fig. 6 .
Fig. 6.The execution time of 2 modes.The x-axis indicates datasets and the y-axis describes execution time.

Table 1 .
Strengths and weaknesses of recommendation algorithms

Table 2 .
The results of statistic analysis on predicting ratings

Table 3 .
Datasets in the experiment , with the increasing of data scale, RMSE generally decreases.Due to the