# Distributed Nonparametric and Semiparametric Regression on SPARK for Big Data Forecasting

Authors: Jelena Fiosina; Maksims Fiosins
Journal: Applied Computational Intelligence and Soft Computing
 (2017)

---

## Abstract

Forecasting in big datasets is a common but complicated task, which cannot be executed using the well-known parametric linear regression. However, nonparametric and semiparametric methods, which enable forecasting by building nonlinear data models, are computationally intensive and lack sufficient scalability to cope with big datasets to extract successful results in a reasonable time. We present distributed parallel versions of some nonparametric and semiparametric regression models. We used MapReduce paradigm and describe the algorithms in terms of SPARK data structures to parallelize the calculations. The forecasting accuracy of the proposed algorithms is compared with the linear regression model, which is the only forecasting model currently having parallel distributed realization within the SPARK framework to address big data problems. The advantages of the parallelization of the algorithm are also provided. We validate our models conducting various numerical experiments: evaluating the goodness of fit, analyzing how increasing dataset size influences time consumption, and analyzing time consumption by varying the degree of parallelism (number of workers) in the distributed realization.


---

## Body

## 1. Introduction

The most current methods of data analysis, data mining, and machine learning should deal with big databases. Cloud Computing technologies can be successfully applied to parallelize standard data mining techniques in order to make working with massive amounts of data feasible [1]. For this purpose, standard algorithms should often be redesigned for parallel environment to distribute computations among multiple computation nodes.One such approach is to use Apache Hadoop, which includes MapReduce for job distribution [2] and distributed file system (HDFS) for data sharing among nodes.Recently, a new and efficient framework called Apache SPARK [3] was built on top of Hadoop, which allows more efficient execution of distributed jobs and therefore is very promising for big data analysis problems [4]. However, SPARK is currently in the development stage, and the number of standard data analysis libraries is limited.R software is a popular instrument for data analysts. It provides several possibilities for parallel data processing through the add-on packages [5]. It is possible also to use Hadoop and SPARK inside of R using SPARKR. This is an R package that provides a lightweight front-end to use Apache SPARK within R. SPARKR is still in the developing stage and supports only some features of SPARK but has a big potential for the future of data science [6].There exist also alternative parallelization approaches, such as Message Passing Interface (MPI) [7]. However, in the present paper, we will concentrate on SPARK because of its speed, simplicity, and scalability [8].In this study, we consider regression-based forecasting for the case where the data has a nonlinear structure, which is common in real-world datasets. This implies that linear regression cannot make accurate forecasts and, thus, we resort to nonparametric and semiparametric regression methods, which do not require linearity and are more robust to outliers. However, the main disadvantage of these methods is that they are very time-consuming, and therefore the term “big data” for such methods starts much earlier than with parametrical approaches. In the case of big datasets, traditional nonparallel realizations are not capable of processing all the available data. This makes it imperative to adapt to existing techniques and to develop new ones that overcome this disadvantage. The distributed parallel SPARK framework gives us the possibility of addressing this difficulty and increasing the scalability of nonparametric and semiparametric regression methods, allowing us to deal with bigger datasets.There are some approaches in the current literature to address nonparametric or semiparametric regression models for parallel processing of big datasets [9], for example, using R add-on packages, MPI. Our study examines a novel, fast, parallel, and distributed realization of the algorithms based on the modern version of Apache SPARK, which is a promising tool for the efficient realization of different machine learning and data mining algorithms [3].The main objective of this study is to enable a parallel distributed version of nonparametric and semiparametric regression models, particularly kernel-density-based and partial linear models to be applied on big data. To realize this, a SPARK MapReduce based algorithm has been developed, which splits the data and performs various algorithm processes in parallel in the map phase and then combines the solutions in the reduce phase to merge the results.More specifically, the contribution of this study is (i) to design novel distributed parallel kernel density regression and partial linear regression algorithms over the SPARK MapReduce paradigm for big data and (ii) to validate the algorithms, analyzing their accuracy, scalability, and speed-up by means of numerical experiments.The remainder of this paper is organized as follows. Section2 reviews the traditional regression models to be analyzed. Section 3 reviews the existent distributed computation frameworks for big datasets. In Section 4, we propose parallel versions of kernel-density-based and partial linear regression model algorithms, based on SPARK MapReduce paradigm. In Section 5, we present the experimental setup and in Section 6 we discuss the experimental framework and analysis. Section 7 concludes the paper and discusses future research opportunities.


## 2. Background: Regression Models

### 2.1. Linear Multivariate Regression

We start with linear regression, which is the only regression model realized in the current version of SPARK to compare the results of the proposed methods.Let us first consider the classical multivariate linear regression modelE(Y∣X)=Xβ [10, 11]:(1)Y=Xβ+ε,where n is a number of observations, d is the number of factors, Yn×1 is a vector of dependent variables, βd×1 is a vector of unknown parameters, εn×1 is a vector of random errors, and Xn×d is a matrix of explanatory variables. The rows of the matrix X correspond to observations and the columns correspond to factors. We suppose that {εi} are mutually independent and have zero expectation and equal variances.The well-known least square estimator (LSE)β^ of β is(2)β^=XTX-1XTY.Further, letxi,yii=1n be the observations sampled from the distribution of (X,Y). After the estimation of the parameters β, we can make a forecast for a certain kth (future) time moment as E(Yk)=xkβ^, where xk is a vector of observed values of explanatory variables for the kth time moment.For big data, it is a problem to perform the matrix operations in (2). For this purpose, other optimization techniques can be used. One effective option is to use the Stochastic Gradient Descent algorithm [12], which is realized in SPARK. The generalized cost function to be minimized is(3)Jβ;X,Y=12nXβ-YTXβ-Y.Algorithm1 presents the Stochastic Gradient Descent algorithm, where α is a learning rate parameter.Algorithm 1:Stochastic Gradient Descent algorithm.
(1)while not converged do
(2)for all  j∈0,d¯  do
(3)βj^←βj^-α∂∂βj^Jβ^;X,Y
(4)end for
(5)end whileAlgorithm1 can be executed iteratively (incrementally) that is easy to parallelize.


### 2.2. Kernel Density Regression

The first alternative to the linear regression model we want to consider is the kernel density estimation-based regression, which is of big importance in the case when data have a nonlinear structure. This nonparametric approach for estimating a regression curve has four main purposes. First, it provides a versatile method for exploring a general relationship between two variables. Second, it can predict observations without a reference to a fixed parametric model. Third, it provides a tool for finding spurious observations by studying the influence of isolated points. Fourth, it constitutes a flexible method of substitution or interpolation between adjacentX-values for missing values [13].Let us consider a nonparametric regression model,m(x)=E(Y∣X=x) [14], with the same Y, X, and ε as for a linear model(4)y=mx+ε.The Nadaraya-Watson kernel estimator [15, 16] of m(x) is(5)mnx=∑i=1nKx-xi/hyi∑i=1nKx-xi/h=∑i=1nKhx-xiyi∑i=1nKhx-xi,where K(u) is the kernel function of Rd, which is a nonnegative real-valued integrable function satisfying the following two requirements: ∫-∞∞K(u)du=1 and K(-u)=K(u) for all values of u; h>0 is a smoothing parameter called bandwidth, Kh(u)=1/hK(u/h). We can see that each value of the historical forecast, yi, is taken with some weight of the corresponding independent variable value of the same observation, xi.In a multidimensional caseE(Y∣X)=m(X), the kernel function KH(x)=H-1K(H-1x), where H is a d×d matrix of smoothing parameters. The choice of the bandwidth matrix H is the most important factor affecting the accuracy of the estimator, since it controls the orientation and amount of smoothing induced. The simplest choice is H=hId, where h is a unidimensional smoothing parameter and Id is d×d identity matrix. Then, we have the same amount of smoothing applied in all coordinate directions. Another relatively easy to manage choice is to take the bandwidth matrix equal to a diagonal matrix H=diag(h1,h2,…,hd), which allows for different amounts of smoothing in each of the coordinates. We implemented the latter in our experiments. The multidimensional kernel function, K(u)=K(u1,u2,…,ud), then is easy to present with univariate kernel functions as K(u)=K(u1)·K(u2)·…·K(ud). We used the Gaussian kernel in our experiments. Then, (5) for the multidimensional case can be rewritten as(6)mnxk=∑i=1nKHxk-xiyi∑i=1nKHxk-xi=∑i=1n∏j=1dKHxk,j-xi,jyi∑i=1n∏j=1dKHxk,j-xi,j.An important problem in a kernel density estimation is the selection of the appropriate bandwidth,h. It has an influence on the structure of the neighborhood in (5): the bigger the value of h selected, the higher the significant influence that xi points have on the estimator mn(xk). In the multidimensional case, H also regulates the balance between factors. The most popular heuristic methods of bandwidth selection are plug-in and resampling methods. However, those heuristics require a substantial amount of computations, which is not possible for big datasets. For our case, we used a well-known rule-of-thumb approach, proposed by Silverman [17], which works for Gaussian kernels. In the case of no correlation between explanatory variables, there is a simple and useful formula for bandwidth selection with Scott’s rule [18]: hj=n-1/(d+4)σj, j=1,2,…,d, where σj is a variance of the jth factor.It is known [14] that the curse of dimensionality is one of the major problems that arises when using nonparametric multivariate regression techniques. For the practitioner, an additional problem is that, for more than two regressors, graphical illustrations or interpretations of the results are hard or even impossible. Truly multivariate regression models are often far too flexible and general for making a detailed inference.A very suitable property of the kernel function is its additive nature. This property makes the kernel function easy to use for distributed data [13]. Unfortunately, such models, even with current parallelization possibilities, remain very time-consuming.


### 2.3. Partial Linear Models

Another alternative to the linear regression model is a semiparametric partial linear regression model (PLM). Currently, several efforts have been allocated to developing methods that reduce the complexity of high dimensional regression problems [14]. The models allow easier interpretation of the effect of each variable and may be preferable to a completely nonparametric model. These refer to the reduction of dimensionality and provide an allowance for partly parametric modelling. On the other hand, PLMs are more flexible than the standard linear model because they combine both parametric and nonparametric components. It is assumed that the response variable Y depends on variable U in a linear way but is nonlinearly related to other independent variables T [19]. The resulting models can be grouped together as so-called semiparametric models. PLM of regression consists of two additive components, a linear and a nonparametric part. PLM of regression is given as(7)EY∣U,T=Uβ+mT,where βp×1 is a finite dimensional vector of parameters of a linear regression part and m(·) is a smooth function. Here, we assume the decomposition of the explanatory variables X into two vectors, U and T. The vector U denotes a p-variate random vector which typically covers categorical explanatory variables or variables that are known to influence the index in a linear way. The vector, T, is a q-variate random vector of continuous explanatory variables that is to be modelled in a nonparametric way, so p+q=d. Economic theory or intuition should ideally guide the inclusion of the regressors in U or T, respectively.An algorithm for the estimation of the PLMs was proposed in [13], which is based on the likelihood estimator and known as generalized Speckman [20] estimator. We reformulated this algorithm (Algorithm 2) in terms of functions and data structures, which can be easily parallelizable in Section 4.Algorithm 2:PLM estimation, training set: [Y,U,T], test set: [Y′,U′,T′].
(1)function SmoothMatrix(T,T′,h)
(2)n←rows(T), n′←rows(T′)
(3)for all  i∈1,n¯, j∈1,n′¯  do
(4)W:Wi,j←KH(Ti-T′j), S:Si,j←Wi,j/∑i=1nWi,j
(5)end for
(6)return  S
(7)end function
(8)
(9)function LinearCoefficients(S,[Y,U,T])
(10)U~←(I-S)U, Y~←(I-S)Y
(11)return  β←U~TU~-1U~TY~
(12)end function
(13)
(14)function   KernelPart(β,[Y,U,T],h,T′)
(15)S←SmoothMatrix(T,T′,h)
(16)return  m(T′)←S(Y-Uβ)
(17)end function
(18)
(19)function PLM([Y,U,T],h,[U′,T′])
(20)    Smooth matrixS←SmoothMatrix(T,T,h)
(21)β←LinearCoefficients(S,[Y,U,T])
(22)m(T′)←KernelPart(β,[Y,U,T],h,T′)
(23)return  Y′←U′β+mT′
(24)end functionP
L
M function is the primary function of Algorithm 2, which takes as parameters the training dataset [Y,U,T], bandwidth vector h, and a test dataset, [U′,T′]. The first step in the estimation is to execute the function, SmoothMatrix, to compute a smoother matrix, S, based on the training data of the nonlinear parts T and h. This helps us to obtain the smoother matrix, which transforms the vector of observations into fitted values. Next, we estimate the linear coefficients of the linear part of the model with the LinearCoefficients function. First, we take into account the influence of the nonlinear part on the linear part of the independent variable, U~←(I-S)U, and on the dependent variable, Y~←(I-S)Y. Then, we use the ordinary equation (2) or Algorithm 1 to obtain the linear coefficients. With these coefficients, we calculate the linear part of the forecast. Next, we calculate the nonlinear part of the forecast, using Nadaraya-Watson estimator (6). Here, we recalculate a smoother matrix, taking into account the test-set data of the nonlinear part. We take also into account the influence of the linear part, Y-Uβ. Finally, we sum the linear and nonlinear part of the forecast to obtain the final result, Y′←U′β+mT′.


## 2.1. Linear Multivariate Regression

We start with linear regression, which is the only regression model realized in the current version of SPARK to compare the results of the proposed methods.Let us first consider the classical multivariate linear regression modelE(Y∣X)=Xβ [10, 11]:(1)Y=Xβ+ε,where n is a number of observations, d is the number of factors, Yn×1 is a vector of dependent variables, βd×1 is a vector of unknown parameters, εn×1 is a vector of random errors, and Xn×d is a matrix of explanatory variables. The rows of the matrix X correspond to observations and the columns correspond to factors. We suppose that {εi} are mutually independent and have zero expectation and equal variances.The well-known least square estimator (LSE)β^ of β is(2)β^=XTX-1XTY.Further, letxi,yii=1n be the observations sampled from the distribution of (X,Y). After the estimation of the parameters β, we can make a forecast for a certain kth (future) time moment as E(Yk)=xkβ^, where xk is a vector of observed values of explanatory variables for the kth time moment.For big data, it is a problem to perform the matrix operations in (2). For this purpose, other optimization techniques can be used. One effective option is to use the Stochastic Gradient Descent algorithm [12], which is realized in SPARK. The generalized cost function to be minimized is(3)Jβ;X,Y=12nXβ-YTXβ-Y.Algorithm1 presents the Stochastic Gradient Descent algorithm, where α is a learning rate parameter.Algorithm 1:Stochastic Gradient Descent algorithm.
(1)while not converged do
(2)for all  j∈0,d¯  do
(3)βj^←βj^-α∂∂βj^Jβ^;X,Y
(4)end for
(5)end whileAlgorithm1 can be executed iteratively (incrementally) that is easy to parallelize.


## 2.2. Kernel Density Regression

The first alternative to the linear regression model we want to consider is the kernel density estimation-based regression, which is of big importance in the case when data have a nonlinear structure. This nonparametric approach for estimating a regression curve has four main purposes. First, it provides a versatile method for exploring a general relationship between two variables. Second, it can predict observations without a reference to a fixed parametric model. Third, it provides a tool for finding spurious observations by studying the influence of isolated points. Fourth, it constitutes a flexible method of substitution or interpolation between adjacentX-values for missing values [13].Let us consider a nonparametric regression model,m(x)=E(Y∣X=x) [14], with the same Y, X, and ε as for a linear model(4)y=mx+ε.The Nadaraya-Watson kernel estimator [15, 16] of m(x) is(5)mnx=∑i=1nKx-xi/hyi∑i=1nKx-xi/h=∑i=1nKhx-xiyi∑i=1nKhx-xi,where K(u) is the kernel function of Rd, which is a nonnegative real-valued integrable function satisfying the following two requirements: ∫-∞∞K(u)du=1 and K(-u)=K(u) for all values of u; h>0 is a smoothing parameter called bandwidth, Kh(u)=1/hK(u/h). We can see that each value of the historical forecast, yi, is taken with some weight of the corresponding independent variable value of the same observation, xi.In a multidimensional caseE(Y∣X)=m(X), the kernel function KH(x)=H-1K(H-1x), where H is a d×d matrix of smoothing parameters. The choice of the bandwidth matrix H is the most important factor affecting the accuracy of the estimator, since it controls the orientation and amount of smoothing induced. The simplest choice is H=hId, where h is a unidimensional smoothing parameter and Id is d×d identity matrix. Then, we have the same amount of smoothing applied in all coordinate directions. Another relatively easy to manage choice is to take the bandwidth matrix equal to a diagonal matrix H=diag(h1,h2,…,hd), which allows for different amounts of smoothing in each of the coordinates. We implemented the latter in our experiments. The multidimensional kernel function, K(u)=K(u1,u2,…,ud), then is easy to present with univariate kernel functions as K(u)=K(u1)·K(u2)·…·K(ud). We used the Gaussian kernel in our experiments. Then, (5) for the multidimensional case can be rewritten as(6)mnxk=∑i=1nKHxk-xiyi∑i=1nKHxk-xi=∑i=1n∏j=1dKHxk,j-xi,jyi∑i=1n∏j=1dKHxk,j-xi,j.An important problem in a kernel density estimation is the selection of the appropriate bandwidth,h. It has an influence on the structure of the neighborhood in (5): the bigger the value of h selected, the higher the significant influence that xi points have on the estimator mn(xk). In the multidimensional case, H also regulates the balance between factors. The most popular heuristic methods of bandwidth selection are plug-in and resampling methods. However, those heuristics require a substantial amount of computations, which is not possible for big datasets. For our case, we used a well-known rule-of-thumb approach, proposed by Silverman [17], which works for Gaussian kernels. In the case of no correlation between explanatory variables, there is a simple and useful formula for bandwidth selection with Scott’s rule [18]: hj=n-1/(d+4)σj, j=1,2,…,d, where σj is a variance of the jth factor.It is known [14] that the curse of dimensionality is one of the major problems that arises when using nonparametric multivariate regression techniques. For the practitioner, an additional problem is that, for more than two regressors, graphical illustrations or interpretations of the results are hard or even impossible. Truly multivariate regression models are often far too flexible and general for making a detailed inference.A very suitable property of the kernel function is its additive nature. This property makes the kernel function easy to use for distributed data [13]. Unfortunately, such models, even with current parallelization possibilities, remain very time-consuming.


## 2.3. Partial Linear Models

Another alternative to the linear regression model is a semiparametric partial linear regression model (PLM). Currently, several efforts have been allocated to developing methods that reduce the complexity of high dimensional regression problems [14]. The models allow easier interpretation of the effect of each variable and may be preferable to a completely nonparametric model. These refer to the reduction of dimensionality and provide an allowance for partly parametric modelling. On the other hand, PLMs are more flexible than the standard linear model because they combine both parametric and nonparametric components. It is assumed that the response variable Y depends on variable U in a linear way but is nonlinearly related to other independent variables T [19]. The resulting models can be grouped together as so-called semiparametric models. PLM of regression consists of two additive components, a linear and a nonparametric part. PLM of regression is given as(7)EY∣U,T=Uβ+mT,where βp×1 is a finite dimensional vector of parameters of a linear regression part and m(·) is a smooth function. Here, we assume the decomposition of the explanatory variables X into two vectors, U and T. The vector U denotes a p-variate random vector which typically covers categorical explanatory variables or variables that are known to influence the index in a linear way. The vector, T, is a q-variate random vector of continuous explanatory variables that is to be modelled in a nonparametric way, so p+q=d. Economic theory or intuition should ideally guide the inclusion of the regressors in U or T, respectively.An algorithm for the estimation of the PLMs was proposed in [13], which is based on the likelihood estimator and known as generalized Speckman [20] estimator. We reformulated this algorithm (Algorithm 2) in terms of functions and data structures, which can be easily parallelizable in Section 4.Algorithm 2:PLM estimation, training set: [Y,U,T], test set: [Y′,U′,T′].
(1)function SmoothMatrix(T,T′,h)
(2)n←rows(T), n′←rows(T′)
(3)for all  i∈1,n¯, j∈1,n′¯  do
(4)W:Wi,j←KH(Ti-T′j), S:Si,j←Wi,j/∑i=1nWi,j
(5)end for
(6)return  S
(7)end function
(8)
(9)function LinearCoefficients(S,[Y,U,T])
(10)U~←(I-S)U, Y~←(I-S)Y
(11)return  β←U~TU~-1U~TY~
(12)end function
(13)
(14)function   KernelPart(β,[Y,U,T],h,T′)
(15)S←SmoothMatrix(T,T′,h)
(16)return  m(T′)←S(Y-Uβ)
(17)end function
(18)
(19)function PLM([Y,U,T],h,[U′,T′])
(20)    Smooth matrixS←SmoothMatrix(T,T,h)
(21)β←LinearCoefficients(S,[Y,U,T])
(22)m(T′)←KernelPart(β,[Y,U,T],h,T′)
(23)return  Y′←U′β+mT′
(24)end functionP
L
M function is the primary function of Algorithm 2, which takes as parameters the training dataset [Y,U,T], bandwidth vector h, and a test dataset, [U′,T′]. The first step in the estimation is to execute the function, SmoothMatrix, to compute a smoother matrix, S, based on the training data of the nonlinear parts T and h. This helps us to obtain the smoother matrix, which transforms the vector of observations into fitted values. Next, we estimate the linear coefficients of the linear part of the model with the LinearCoefficients function. First, we take into account the influence of the nonlinear part on the linear part of the independent variable, U~←(I-S)U, and on the dependent variable, Y~←(I-S)Y. Then, we use the ordinary equation (2) or Algorithm 1 to obtain the linear coefficients. With these coefficients, we calculate the linear part of the forecast. Next, we calculate the nonlinear part of the forecast, using Nadaraya-Watson estimator (6). Here, we recalculate a smoother matrix, taking into account the test-set data of the nonlinear part. We take also into account the influence of the linear part, Y-Uβ. Finally, we sum the linear and nonlinear part of the forecast to obtain the final result, Y′←U′β+mT′.


## 3. Background: MapReduce, Hadoop, and SPARK

MapReduce [2] is one of the most popular programming models to deal with big data. It was proposed by Google in 2004 and was designed for processing huge amounts of data using a cluster of machines. The MapReduce paradigm is composed of two phases: map and reduce. In general terms, in the map phase, the input dataset is processed in parallel producing some intermediate results. Then, the reduce phase combines these results in some way to form the final output. The most popular implementation of the MapReduce programming model is Apache Hadoop, an open-source framework that allows the processing and management of large datasets in a distributed computing environment. Hadoop works on top of the Hadoop Distributed File System (HDFS), which replicates the data files in many storage nodes, facilitates rapid data transfer rates among nodes, and allows the system to continue operating uninterruptedly in case of a node failure.Another Apache project that also uses MapReduce as a programming model, but with much richer APIs in Java, Scala, Python, and R, is SPARK [3]. SPARK is intended to enhance, not replace, the Hadoop stack. SPARK is more than a distributed computational framework originally developed in the UC Berkeley AMP Lab for large-scale data processing that improves the efficiency by the use of intensive memory. It also provides several prebuilt components empowering users to implement applications faster and easier. SPARK uses more RAM instead of network and disk I/O and is relatively fast as compared to Hadoop MapReduce.From an architecture perspective, Apache SPARK is based on two key concepts; Resilient Distributed Datasets (RDDs) and directed acyclic graph (DAG) execution engine. With regard to datasets, SPARK supports two types of RDDs: parallelized collections that are based on existing Scala collections and Hadoop datasets that are created from the files stored by the HDFS. RDDs support two kinds of operations: transformations and actions. Transformations create new datasets from the input (e.g., map or filter operations are transformations), whereas actions return a value after executing calculations on the dataset (e.g., reduce or count operations are actions). The DAG engine helps to eliminate the MapReduce multistage execution model and offers significant performance improvements.RDDs [21] are distributed memory abstractions that allow programmers to perform in-memory computations on large clusters while retaining the fault tolerance of data flow models like MapReduce. RDDs are motivated by two types of applications that current data flow systems handle inefficiently: iterative algorithms, which are common in graph applications and machine learning, and interactive data mining tools. In both cases, keeping data in memory can improve performance by an order of magnitude. To achieve fault tolerance efficiently, RDDs provide a highly restricted form of shared memory; they are read-only datasets that can only be constructed through bulk operations on other RDDs. This in-memory processing is a faster process as there is no time spent in moving the data/processes in and out of the disk, whereas MapReduce requires a substantial amount of time to perform these I/O operations, thereby increasing latency.SPARK uses a master/worker architecture. There is a driver that talks to a single coordinator, called the master, that manages workers in which executors run (see Figure1).Figure 1
SPARK distributed architecture.SPARK uses HDFS and has high-level libraries for stream processing, machine learning, and graph processing, such as MLlib [22]. For this study, linear regression realization included in MLlib [23] was used to evaluate the proposed distributed PLM algorithm.In this paper, Apache SPARK is used to implement the proposed distributed PML algorithm, as described in Section4.


## 4. Distributed Parallel Partial Linear Regression Model

### 4.1. Distributed Partial Linear Model Estimation

In this section, we continue to discuss kernel-density-based and partial linear models (PLMs), described in Section2. Next, we consider kernel-density-based regression as a specific case of PLM, when the parametric linear part is empty. The general realization of PLM algorithm allows us to conduct experiments with nonparametric kernel-density-based regression. We discuss how to distribute the computations of Algorithm 2 to increase the speed and scalability of the approach. As we can see from the previous subsection, PLM presupposes several matrix operations, which requires a substantial amount of computational demands [24] and, therefore, is not feasible for application to big datasets. In this section, we focus our attention on (1) how to organize matrix computations in a maximally parallel and effective manner and (2) how to parallelize the overall computation process of the PLM estimation. SPARK provides us with various types of parallel structures. Our first task is to select the appropriate SPARK data structures to facilitate the computation process. Next, we develop algorithms, which execute a PLM estimation (Algorithm 2) using MapReduce and SPARK principles.Traditional methods of data analysis, especially based on matrix computations, must be adapted for running on a cluster, as we cannot readily reuse linear algebra algorithms that are available for single-machine situations. A key idea is to distribute operations, separating algorithms into portions that require matrix operations versus vector operations. Since matrices are often quadratically larger than vectors, a reasonable assumption is that vectors are stored in memory on a single machine, while for matrices it is not reasonable or feasible. Instead, the matrices are stored in blocks (rectangular pieces or some rows/columns), and the corresponding algorithms for block matrices are implemented. The most challenging of tasks here is the rebuilding of algorithms from single-core modes of computation to operate on distributed matrices in parallel [24].Similar to a linear regression forecasting process, PLM forecasting, because of its parametric component, assumes training and estimating steps. Distributed architectures of Hadoop and SPARK assume one driver computer and several worker computers, which perform computations in parallel. We take this architecture into account while developing our algorithms.Let us describe the training procedure with the purpose of computing theβ parameter, presented in Figure 2. This part was very computationally intensive and could not be calculated without appropriate parallelization of computations.Figure 2
PLM parallel training.First, the driver computer reads the training data,[Y,U,T], from a file or database, divides the data into various RDD partitions, and distributes among the workers, [Y(i),U(i),T(i)]. Next, the training process involves the following steps:(1)
Each worker makes an initial preprocessing and transformation of[Y(i),U(i),T(i)], which include scaling and formatting.(2)
The driver program accesses all preprocessed data.(3)
The driver program collects all the preprocessed data and broadcasts them to all the workers.(4)
Then, each worker makes its own copy of the training data[Y,U,T].(5)
A smoother matrix,W, is computed in parallel. Since the rows of W are divided into partitions, each worker then computes its part W(i).(6)
Each worker computes the sum of elements in each row within its partitionW(i): ∑jWj(i), which is then saved as a RDD.(7)
We do not actually need the normalized matrixS itself, which could be computed as Wj(i)/∑jWj(i), but only (I-S) as RDD, which is the part directly computed by each worker: (I-S(i)).(8)
Using theith part of matrix (I-S), we multiply it from the right side with the corresponding elements of matrix U. Thus, we obtain the ith part of transformed matrix U~(i) as a RDD. The ith part of transformed matrix Y~(i) as RDD is computed analogously.(9)
Finally, the driver program accesses and collects matricesU~ and Y~.(10)
The driver program initializes computing of the standard linear regression algorithm,LinearRegressionModelWithSGD, which is realized in SPARK.(11)
The parametersβ are computed in parallel.(12)
Then,β are accessed by the driver computer.Let us now describe the forecasting process (Figure3), which occurs after the parametric part of the PLM has completed its estimation. Note that the kernel part of the model is nonparametric and is directly computed for each forecasted data point.Figure 3
PLM parallel forecasting.Since the forecasting is performed after the training process, then the preprocessed training set is already distributed among the workers and is available as a RDD. The PLM distributed forecasting procedure includes the following steps:(1)
The driver program broadcasts the estimated linear part coefficients,β, to the workers.(2)
Receiving new observation[u′,t′], the driver program broadcasts it to all the workers.(3)
Each worker receives its copy of[u′,t′] and β.(4)
We compute a smoother matrixW, which is in a vector form. This computation is also partitioned among the workers (see (5)), so the ith worker computes W(i) as particular columns of W.(5)
Each worker computes partial sums of the rows of the matrixW(i) elements and shares the partial sums with the driver program.(6)
The driver program accesses the partial sums and performs reducing step to obtain the final sum,∑iW(i).(7)
The driver program broadcasts the final sum to all the workers.(8)
Each worker receives the final sum,∑iW(i).(9)
Each worker computes its columns of the smoother matrixS(i).(10)
Based on the RDD part[Y(i),U(i),T(i)] (known from the training step), each worker computes the linear part of the forecast for training data. It was necessary to identify the kernel part of the forecast, performing subtraction of the linear part from the total forecast, the values of which were known from the training set.(11)
Each worker computes the kernel part of the forecastm(t′)(i) as RDD and shares with the driver program.(12)
The driver program accesses the partial kernel forecastsm(t′)(i).(13)
The driver program performs the reducing step to make the final forecast, combining the accessed kernel parts and computing the linear part:y′=u′β+∑im(t′)(i).


### 4.2. Case Studies

We illustrate the distributed execution of PLM algorithm with a simple numerical example. First, the driver computer reads the training data,[Y,U,T]: (8)Y,U,T=YUT12341223212212232111.We suppose that the algorithm is being executed in parallel on two workers. The driver accesses[Y,U,T] and creates the corresponding RDDs.First, data preprocessing takes place. This job is shared between the workers in a standard way, and the result is returned to the driver. We do not change our data at this stage for illustrative purposes.The goal of the training process is to compute the coefficientsβ of the linear part. First, the matrices [Y,U,T] are divided into the parts by rows: (9)Y,U,T=Y1,U1,T1Y2,U2,T2=Y1U1T11121222323Y1U2T23212142211.Each workeri accesses its part of data [Y(i),Ui,Ti], and it has access to the whole data.Each worker computes its part of the smoother matrixS(i), in particular: (10)S=S1S2=SmoothMatrixT1,TSmoothMatrixT2,T.The first worker obtains the elements of smoother matrixS(1) (it gets directly matrix I-S(i)); the corresponding elements of matrix W(1) should be computed first. For example, to get the element W1,3(1) according to the function SmoothMatrix, (11)W1,31=KHT11-T3=KH1,2-2,1=KH-1,1=K-2,2=0.007.Then, matrixW for both workers is the following: (12)W=W1W2=0.3990.0070.0070.0540.0070.3990.0000.0000.0070.0000.3990.0540.0540.0000.0540.399.To get the elementI-S11,3 knowing matrix W1 according to the functionSmoothMatrix, we compute (13)I-S11,3=-0.0070.399+0.007+0.007+0.005=-0.016.Then, matrix I-S for both workers is the following: (14)I-S=I-S1I-S2=0.147-0.016-0.016-0.115-0.0180.018-0.000-0.000-0.016-0.0000.133-0.117-0.106-0.000-0.1070.213.Then, the corresponding smoothed matricesU~ and Y~ computed by both workers are (15)U~=U~1U~2=-0.147-0.0000.0180.0190.016-0.1340.1060.106,Y~=Y~1Y~2=-0.3930.018-0.0850.426.MatricesU~(1) and U~(2) are sent to the driver and collected into the matrix U~, but Y~(1) and Y~(2) are collected into the vector Y~.The driver program calls the standard procedure of regression coefficient calculation, which is shared between workers in a standard way. The resulting coefficientsβ are collected on the driver: (16)β=β0β1β2=-0.0022.7531.041.At the forecasting stage, each worker receives a set of points for forecasting. Now, we illustrate the algorithm for a single point[u′,t′]=2,1,1,1 and two workers.Each workeri accesses its part of training data [Y(i),U(i),T(i)] and computes then the elements of matrix S(i)=SmoothMatrix(Ti,t′). First, smoother matrix W(i) should be computed. For example, worker 1 computes the element (17)W1,11=KH1,2-2,1=KH-1,1=K-2,2=0.007.So, workers 1 and 2 obtain matrices(18)W=W1W2=0.0070.0000.3990.054.Now, each worker computes partial sums (so for worker 1,W1,1(1)+W1,2(1)=0.007+0.000=0.007; for worker 2, 0.399+0.054=0.453) and shares them to the driver program. The driver computes the total sum 0.007+0.453=0.46 and sends it to the workers.Now, each worker computes matrixS(i). For example, worker 1 computes the element S1,1(1)=0.007/0.46=0.016.Then, matricesS(i) for both workers are (19)S=S1S2=0.0160.0000.8670.117.Now, each worker computesU(i)β and the corresponding difference Y-U(i)β: (20)Uβ=U1βU2β=4.838.636.557.59,Y-Uβ=Y1-U1βY2-U2β=-3.83-6.63-3.55-3.59.Each worker computes the smoothed value of the kernel part of the forecast:(21)mit′=SiYi-Uiβ,so m1(t′)=-0.0628 and m2(t′)=-3.49. These values are shared with the driver program. It computes their sum, which is considered as a kernel part of the prediction: m(t′)=-3.56.The driver program computes the linear part of the prediction,u′β=3.79, and the final forecast, y′=u′β+m(t′)=0.236.In the next sections, we evaluate the performance of the proposed algorithms by various numerical experiments.


## 4.1. Distributed Partial Linear Model Estimation

In this section, we continue to discuss kernel-density-based and partial linear models (PLMs), described in Section2. Next, we consider kernel-density-based regression as a specific case of PLM, when the parametric linear part is empty. The general realization of PLM algorithm allows us to conduct experiments with nonparametric kernel-density-based regression. We discuss how to distribute the computations of Algorithm 2 to increase the speed and scalability of the approach. As we can see from the previous subsection, PLM presupposes several matrix operations, which requires a substantial amount of computational demands [24] and, therefore, is not feasible for application to big datasets. In this section, we focus our attention on (1) how to organize matrix computations in a maximally parallel and effective manner and (2) how to parallelize the overall computation process of the PLM estimation. SPARK provides us with various types of parallel structures. Our first task is to select the appropriate SPARK data structures to facilitate the computation process. Next, we develop algorithms, which execute a PLM estimation (Algorithm 2) using MapReduce and SPARK principles.Traditional methods of data analysis, especially based on matrix computations, must be adapted for running on a cluster, as we cannot readily reuse linear algebra algorithms that are available for single-machine situations. A key idea is to distribute operations, separating algorithms into portions that require matrix operations versus vector operations. Since matrices are often quadratically larger than vectors, a reasonable assumption is that vectors are stored in memory on a single machine, while for matrices it is not reasonable or feasible. Instead, the matrices are stored in blocks (rectangular pieces or some rows/columns), and the corresponding algorithms for block matrices are implemented. The most challenging of tasks here is the rebuilding of algorithms from single-core modes of computation to operate on distributed matrices in parallel [24].Similar to a linear regression forecasting process, PLM forecasting, because of its parametric component, assumes training and estimating steps. Distributed architectures of Hadoop and SPARK assume one driver computer and several worker computers, which perform computations in parallel. We take this architecture into account while developing our algorithms.Let us describe the training procedure with the purpose of computing theβ parameter, presented in Figure 2. This part was very computationally intensive and could not be calculated without appropriate parallelization of computations.Figure 2
PLM parallel training.First, the driver computer reads the training data,[Y,U,T], from a file or database, divides the data into various RDD partitions, and distributes among the workers, [Y(i),U(i),T(i)]. Next, the training process involves the following steps:(1)
Each worker makes an initial preprocessing and transformation of[Y(i),U(i),T(i)], which include scaling and formatting.(2)
The driver program accesses all preprocessed data.(3)
The driver program collects all the preprocessed data and broadcasts them to all the workers.(4)
Then, each worker makes its own copy of the training data[Y,U,T].(5)
A smoother matrix,W, is computed in parallel. Since the rows of W are divided into partitions, each worker then computes its part W(i).(6)
Each worker computes the sum of elements in each row within its partitionW(i): ∑jWj(i), which is then saved as a RDD.(7)
We do not actually need the normalized matrixS itself, which could be computed as Wj(i)/∑jWj(i), but only (I-S) as RDD, which is the part directly computed by each worker: (I-S(i)).(8)
Using theith part of matrix (I-S), we multiply it from the right side with the corresponding elements of matrix U. Thus, we obtain the ith part of transformed matrix U~(i) as a RDD. The ith part of transformed matrix Y~(i) as RDD is computed analogously.(9)
Finally, the driver program accesses and collects matricesU~ and Y~.(10)
The driver program initializes computing of the standard linear regression algorithm,LinearRegressionModelWithSGD, which is realized in SPARK.(11)
The parametersβ are computed in parallel.(12)
Then,β are accessed by the driver computer.Let us now describe the forecasting process (Figure3), which occurs after the parametric part of the PLM has completed its estimation. Note that the kernel part of the model is nonparametric and is directly computed for each forecasted data point.Figure 3
PLM parallel forecasting.Since the forecasting is performed after the training process, then the preprocessed training set is already distributed among the workers and is available as a RDD. The PLM distributed forecasting procedure includes the following steps:(1)
The driver program broadcasts the estimated linear part coefficients,β, to the workers.(2)
Receiving new observation[u′,t′], the driver program broadcasts it to all the workers.(3)
Each worker receives its copy of[u′,t′] and β.(4)
We compute a smoother matrixW, which is in a vector form. This computation is also partitioned among the workers (see (5)), so the ith worker computes W(i) as particular columns of W.(5)
Each worker computes partial sums of the rows of the matrixW(i) elements and shares the partial sums with the driver program.(6)
The driver program accesses the partial sums and performs reducing step to obtain the final sum,∑iW(i).(7)
The driver program broadcasts the final sum to all the workers.(8)
Each worker receives the final sum,∑iW(i).(9)
Each worker computes its columns of the smoother matrixS(i).(10)
Based on the RDD part[Y(i),U(i),T(i)] (known from the training step), each worker computes the linear part of the forecast for training data. It was necessary to identify the kernel part of the forecast, performing subtraction of the linear part from the total forecast, the values of which were known from the training set.(11)
Each worker computes the kernel part of the forecastm(t′)(i) as RDD and shares with the driver program.(12)
The driver program accesses the partial kernel forecastsm(t′)(i).(13)
The driver program performs the reducing step to make the final forecast, combining the accessed kernel parts and computing the linear part:y′=u′β+∑im(t′)(i).


## 4.2. Case Studies

We illustrate the distributed execution of PLM algorithm with a simple numerical example. First, the driver computer reads the training data,[Y,U,T]: (8)Y,U,T=YUT12341223212212232111.We suppose that the algorithm is being executed in parallel on two workers. The driver accesses[Y,U,T] and creates the corresponding RDDs.First, data preprocessing takes place. This job is shared between the workers in a standard way, and the result is returned to the driver. We do not change our data at this stage for illustrative purposes.The goal of the training process is to compute the coefficientsβ of the linear part. First, the matrices [Y,U,T] are divided into the parts by rows: (9)Y,U,T=Y1,U1,T1Y2,U2,T2=Y1U1T11121222323Y1U2T23212142211.Each workeri accesses its part of data [Y(i),Ui,Ti], and it has access to the whole data.Each worker computes its part of the smoother matrixS(i), in particular: (10)S=S1S2=SmoothMatrixT1,TSmoothMatrixT2,T.The first worker obtains the elements of smoother matrixS(1) (it gets directly matrix I-S(i)); the corresponding elements of matrix W(1) should be computed first. For example, to get the element W1,3(1) according to the function SmoothMatrix, (11)W1,31=KHT11-T3=KH1,2-2,1=KH-1,1=K-2,2=0.007.Then, matrixW for both workers is the following: (12)W=W1W2=0.3990.0070.0070.0540.0070.3990.0000.0000.0070.0000.3990.0540.0540.0000.0540.399.To get the elementI-S11,3 knowing matrix W1 according to the functionSmoothMatrix, we compute (13)I-S11,3=-0.0070.399+0.007+0.007+0.005=-0.016.Then, matrix I-S for both workers is the following: (14)I-S=I-S1I-S2=0.147-0.016-0.016-0.115-0.0180.018-0.000-0.000-0.016-0.0000.133-0.117-0.106-0.000-0.1070.213.Then, the corresponding smoothed matricesU~ and Y~ computed by both workers are (15)U~=U~1U~2=-0.147-0.0000.0180.0190.016-0.1340.1060.106,Y~=Y~1Y~2=-0.3930.018-0.0850.426.MatricesU~(1) and U~(2) are sent to the driver and collected into the matrix U~, but Y~(1) and Y~(2) are collected into the vector Y~.The driver program calls the standard procedure of regression coefficient calculation, which is shared between workers in a standard way. The resulting coefficientsβ are collected on the driver: (16)β=β0β1β2=-0.0022.7531.041.At the forecasting stage, each worker receives a set of points for forecasting. Now, we illustrate the algorithm for a single point[u′,t′]=2,1,1,1 and two workers.Each workeri accesses its part of training data [Y(i),U(i),T(i)] and computes then the elements of matrix S(i)=SmoothMatrix(Ti,t′). First, smoother matrix W(i) should be computed. For example, worker 1 computes the element (17)W1,11=KH1,2-2,1=KH-1,1=K-2,2=0.007.So, workers 1 and 2 obtain matrices(18)W=W1W2=0.0070.0000.3990.054.Now, each worker computes partial sums (so for worker 1,W1,1(1)+W1,2(1)=0.007+0.000=0.007; for worker 2, 0.399+0.054=0.453) and shares them to the driver program. The driver computes the total sum 0.007+0.453=0.46 and sends it to the workers.Now, each worker computes matrixS(i). For example, worker 1 computes the element S1,1(1)=0.007/0.46=0.016.Then, matricesS(i) for both workers are (19)S=S1S2=0.0160.0000.8670.117.Now, each worker computesU(i)β and the corresponding difference Y-U(i)β: (20)Uβ=U1βU2β=4.838.636.557.59,Y-Uβ=Y1-U1βY2-U2β=-3.83-6.63-3.55-3.59.Each worker computes the smoothed value of the kernel part of the forecast:(21)mit′=SiYi-Uiβ,so m1(t′)=-0.0628 and m2(t′)=-3.49. These values are shared with the driver program. It computes their sum, which is considered as a kernel part of the prediction: m(t′)=-3.56.The driver program computes the linear part of the prediction,u′β=3.79, and the final forecast, y′=u′β+m(t′)=0.236.In the next sections, we evaluate the performance of the proposed algorithms by various numerical experiments.


## 5. Experimental Setup

### 5.1. Performance Evaluation Metrics

#### 5.1.1. Parameters

In our study, we divided the available datasets into two parts: training dataset and test dataset. The training dataset was used to train the model and the test dataset was used to check the accuracy of the results. The sizes of the training and test datasets were the important parameters as they influenced accuracy, scalability, and speed-up metrics.Another important parameter was the level of parallelism, which we considered in the number of cores used. We varied this parameter between 1 (no parallelism) and 48 cores.We also considered processing (learning) time as an important parameter to compare the methods. In most of our experiments, we varied one parameter and fixed the remaining parameters.We conducted three kinds of experiments.


#### 5.1.2. Accuracy Experiments

In the accuracy experiments, we evaluated the goodness of fit that depended on the sizes of training and test datasets. As the accuracy criterion, we used the coefficient of determinationR2, which is usually a quality metric for regression model. It is defined as a relative part of the sum of squares explained by the regression and can be calculated as(22)R2=1-SSresSStot=1-∑iyi-yi^2∑iyi-y¯2,where y¯=∑i=1nyi/n and yi^ is the estimation (prediction) of yi calculated by the regression model.Note that we calculatedR2 using test dataset. Thus, the results were more reliable, because we trained our model on one piece of data (training set) but checked the accuracy of the model on the other one (test set).


#### 5.1.3. Scalability Experiments

Next, we tested the proposed methods on big data. We analyzed how increasing the size of the dataset influences the time consumption of the algorithm. First, we discussed how the execution time changed with the increasing of the size of the dataset. Then, we analyzed how methods accuracy depends on the execution (training) time under different conditions. Scalability was measured with the fixed number of cores.


#### 5.1.4. Speed-Up Experiments

Finally, we analyzed the relationship between time consumption and the degree of parallelism (number of cores) in the distributed realization. We varied the various parallelization degrees and compared the speed of work of various methods. The speed was measured with the fixed accuracy and scale.


### 5.2. Hardware and Software Used

The experiments were carried out on a cluster of 16 computing nodes. Each one of these computing nodes had the following features: processors: 2x Intel Xeon CPU E5-2620, cores: 4 per node (8 threads), clock speed: 2.00 GHz, cache: 15 MB, network: QDR InfiniBand (40 Gbps), hard drive: 2TB, RAM: 16 GB per node.Both Hadoop master processes the NameNode and the JobTracker were hosted in the master node. The former controlled the HDFS, coordinating the slave machines by means of their respective DataNode processes, while the latter was in charge of the TaskTrackers of each computing node, which executed the MapReduce framework. We used a standalone SPARK cluster, which followed a similar configuration, as the master process was located on the master node, and the worker processes were executed on the slave machines. Both frameworks shared the underlying HDFS file system.These are the details of the software used for the experiments: MapReduce implementation: Hadoop version 2.6.0, SPARK version 1.5.2, operating system: CentOS 6.6.


### 5.3. Datasets

We used three datasets: synthetic data, airlines data, and Hanover traffic data. The main characteristics of these datasets are summarized in Table1. Table 2 presents sample records for each dataset.Table 1
Characteristics of the datasets.
Dataset
Number of records
Number of factors
Synthetic data
10,000
2
Traffic data
6,500
7
Airlines delays
120,000,000 (13,000)
29 + 22 (10)Table 2
Fragments of datasets.
(a)
Synthetic dataset
y
x
1
x
2
2.31
0.87
1.26
1.45
1.27
−0.36
−0.5
0.47
−0.06
−1.9
−0.94
1.51
−1.51
0.33
1.72
−0.09
−0.1
−1.71
0.17
0.24
1.64
1.8
0.07
0.77
−0.5
0.45
−0.22
0.76
0.94
1.32
(b)
Hanover dataset
y: travel time
x
1: length
x
2: speed
x
3: stops
x
4: congestion
x
5: tr. lights
x
6: left turns
256
2107.51
30.30
2.10
42.43
225
0
284
2349.74
22.36
4.89
85.56
289
4
162
1248.51
19.33
9.27
85.91
81
1
448
2346.80
20.58
8.39
86.60
289
1
248
352.67
19.33
9.27
85.91
25
1
327
907.30
23.54
3.96
86.95
100
0
443.5
1093.29
22.01
5.44
88.66
169
0
294
348.35
23.68
3.81
89.33
25
0
125.5
1236.62
18.97
10.65
85.21
81
1
511.5
357.23
19.96
7.66
84.85
25
1
(c)
Airlines dataset
DepDelay
DayOfWeek
Distance
MeanVis
MeanWind
Thunderstorm
Precipitationmm
WindDirDegrees
Num
Dest
DepTime
0
3
588
24
14
0
12.7
333
18
SNA
2150
63
7
546
22
13
0
1.78
153
2
GEG
2256
143
5
919
24
18
0
9.14
308
27
MCI
2203
−4
6
599
22
16
0
11.68
161
23
SFO
2147
4
6
368
24
14
0
7.62
151
22
LAS
2159
19
5
188
20
35
0
1.02
170
23
IDA
2204
25
7
291
23
19
0
0
128
22
BOI
2200
1
6
585
17
10
0
6.6
144
25
SJC
2151
0
3
507
28
13
0
9.91
353
24
PHX
2150
38
2
590
28
23
0
0
176
7
LAX
2243Synthetic Data. We started with synthetic data in order to check how the partially linear regression performs on partially linear data and to compute the basic performance characteristics that depended on training and test set sizes. We took the following model: (23)y=0.5x1+x2sin⁡x2+ε,where x1 and x2 were independently uniformly distributed in the interval [0;1000] and ε~N(0;50). The dependence on x2 was clearly nonlinear and strictly fluctuating.Hanover Traffic Data. In [25], we simulated a traffic network in the southern part of Hanover, Germany, on the base of real traffic data. In this study, we used this simulation data as a dataset. The network contained three parallel and five perpendicular streets, which formed 15 intersections with a flow of approximately 5000 vehicles per hour. For our experiments, 6 variables were used: y travel time (min), x1 length of the route (km), x2 average speed in the system (km/h), x3 average number of stops in the system (units/min), x4 congestion level of the flow (veh/h), x5 traffic lights in the route (units), and x6 left turns in the route (units).For the Hanover traffic data, we solved the problem of travel time predictions. We did not filter the dataset and instead used the data in the original form. Principally, the analysis of outliers allows deleting suspicious observations to obtain more accurate results; however, some important information can be lost [26].Taking different subsets of variables, we found that the following variable assignment to linear and kernel parts of PLM is optimal:(i)
Linear partU: x4, x6(ii)
Kernel partT: x1, x2, x3, x5Airlines Data. The data consists of flight arrival and departure details for all commercial flights within the USA, from October 1987 to April 2008 [27]. This is a large dataset: there are nearly 120 million records in total, taking up 12 gigabytes. Every row in the dataset includes 29 variables. This data was used in various studies for analyzing the efficiency of methods proposed for big data processing, including regression [28]. In order to complement this data and to obtain a better prediction, we added weather average daily information, including daily temperatures (min/max), wind speed, snow conditions, and precipitation, which is freely available from the site https://www.wunderground.com/. This provided an additional 22 factors for each of the 731 days. The airlines and weather datasets were joined on the corresponding date.For this data, we aimed to solve the problem of the departure delay prediction, which corresponded to the DepDelay column of data.For test purposes, we selected the Salt Lake City International Airport (SLC). Our experiments showed that construction of a model for several airports resulted in poor results; this required special clustering [29] and could be the subject of future research.Therefore, we selected two years (1995 and 1996) for our analysis. This yielded approximately 170,000 records.An additional factor, which was added to this data, was the number of flights 30 minutes before and 30 minutes after the specific flight.The initial analysis showed the heterogeneous structure of this data. Clustering showed that two variables are the most important for separating the data: departure time and travel distance. A very promising cluster with good prediction potential was short late flights (DepTime ≥ 21:45 and Distance ≤ 1000 Km). They could provide relatively good predictions; however, the distribution of delays did not significantly differ from the original dataset. This cluster contained approximately 13,000 records.In subsequent experiments, we used subsets from this data in order to demonstrate the influence of dataset sizes on the prediction quality.For the PLM algorithm, the first important issue was how to divide the variables for the linear and kernel parts of the regression. Taking different subsets of variables and including/excluding variables one by one, we found 10 most significant variables and the following optimal subsets:(i)
Linear partU: distance of the flight (Distance), average visibility distance (MeanVis), average wind speed (MeanWind), average precipitation (Precipitationmm), wind direction (WindDirDegrees), number of flights in 30-minute interval (Num), and departure time (DepTime)(ii)
Kernel partT: day of the week (DayOfWeek), thunderstorm (0 or 1), and destination (Dest)Table2 presents data fragments of 10 random records from each training dataset.


## 5.1. Performance Evaluation Metrics

### 5.1.1. Parameters

In our study, we divided the available datasets into two parts: training dataset and test dataset. The training dataset was used to train the model and the test dataset was used to check the accuracy of the results. The sizes of the training and test datasets were the important parameters as they influenced accuracy, scalability, and speed-up metrics.Another important parameter was the level of parallelism, which we considered in the number of cores used. We varied this parameter between 1 (no parallelism) and 48 cores.We also considered processing (learning) time as an important parameter to compare the methods. In most of our experiments, we varied one parameter and fixed the remaining parameters.We conducted three kinds of experiments.


### 5.1.2. Accuracy Experiments

In the accuracy experiments, we evaluated the goodness of fit that depended on the sizes of training and test datasets. As the accuracy criterion, we used the coefficient of determinationR2, which is usually a quality metric for regression model. It is defined as a relative part of the sum of squares explained by the regression and can be calculated as(22)R2=1-SSresSStot=1-∑iyi-yi^2∑iyi-y¯2,where y¯=∑i=1nyi/n and yi^ is the estimation (prediction) of yi calculated by the regression model.Note that we calculatedR2 using test dataset. Thus, the results were more reliable, because we trained our model on one piece of data (training set) but checked the accuracy of the model on the other one (test set).


### 5.1.3. Scalability Experiments

Next, we tested the proposed methods on big data. We analyzed how increasing the size of the dataset influences the time consumption of the algorithm. First, we discussed how the execution time changed with the increasing of the size of the dataset. Then, we analyzed how methods accuracy depends on the execution (training) time under different conditions. Scalability was measured with the fixed number of cores.


### 5.1.4. Speed-Up Experiments

Finally, we analyzed the relationship between time consumption and the degree of parallelism (number of cores) in the distributed realization. We varied the various parallelization degrees and compared the speed of work of various methods. The speed was measured with the fixed accuracy and scale.


## 5.1.1. Parameters

In our study, we divided the available datasets into two parts: training dataset and test dataset. The training dataset was used to train the model and the test dataset was used to check the accuracy of the results. The sizes of the training and test datasets were the important parameters as they influenced accuracy, scalability, and speed-up metrics.Another important parameter was the level of parallelism, which we considered in the number of cores used. We varied this parameter between 1 (no parallelism) and 48 cores.We also considered processing (learning) time as an important parameter to compare the methods. In most of our experiments, we varied one parameter and fixed the remaining parameters.We conducted three kinds of experiments.


## 5.1.2. Accuracy Experiments

In the accuracy experiments, we evaluated the goodness of fit that depended on the sizes of training and test datasets. As the accuracy criterion, we used the coefficient of determinationR2, which is usually a quality metric for regression model. It is defined as a relative part of the sum of squares explained by the regression and can be calculated as(22)R2=1-SSresSStot=1-∑iyi-yi^2∑iyi-y¯2,where y¯=∑i=1nyi/n and yi^ is the estimation (prediction) of yi calculated by the regression model.Note that we calculatedR2 using test dataset. Thus, the results were more reliable, because we trained our model on one piece of data (training set) but checked the accuracy of the model on the other one (test set).


## 5.1.3. Scalability Experiments

Next, we tested the proposed methods on big data. We analyzed how increasing the size of the dataset influences the time consumption of the algorithm. First, we discussed how the execution time changed with the increasing of the size of the dataset. Then, we analyzed how methods accuracy depends on the execution (training) time under different conditions. Scalability was measured with the fixed number of cores.


## 5.1.4. Speed-Up Experiments

Finally, we analyzed the relationship between time consumption and the degree of parallelism (number of cores) in the distributed realization. We varied the various parallelization degrees and compared the speed of work of various methods. The speed was measured with the fixed accuracy and scale.


## 5.2. Hardware and Software Used

The experiments were carried out on a cluster of 16 computing nodes. Each one of these computing nodes had the following features: processors: 2x Intel Xeon CPU E5-2620, cores: 4 per node (8 threads), clock speed: 2.00 GHz, cache: 15 MB, network: QDR InfiniBand (40 Gbps), hard drive: 2TB, RAM: 16 GB per node.Both Hadoop master processes the NameNode and the JobTracker were hosted in the master node. The former controlled the HDFS, coordinating the slave machines by means of their respective DataNode processes, while the latter was in charge of the TaskTrackers of each computing node, which executed the MapReduce framework. We used a standalone SPARK cluster, which followed a similar configuration, as the master process was located on the master node, and the worker processes were executed on the slave machines. Both frameworks shared the underlying HDFS file system.These are the details of the software used for the experiments: MapReduce implementation: Hadoop version 2.6.0, SPARK version 1.5.2, operating system: CentOS 6.6.


## 5.3. Datasets

We used three datasets: synthetic data, airlines data, and Hanover traffic data. The main characteristics of these datasets are summarized in Table1. Table 2 presents sample records for each dataset.Table 1
Characteristics of the datasets.
Dataset
Number of records
Number of factors
Synthetic data
10,000
2
Traffic data
6,500
7
Airlines delays
120,000,000 (13,000)
29 + 22 (10)Table 2
Fragments of datasets.
(a)
Synthetic dataset
y
x
1
x
2
2.31
0.87
1.26
1.45
1.27
−0.36
−0.5
0.47
−0.06
−1.9
−0.94
1.51
−1.51
0.33
1.72
−0.09
−0.1
−1.71
0.17
0.24
1.64
1.8
0.07
0.77
−0.5
0.45
−0.22
0.76
0.94
1.32
(b)
Hanover dataset
y: travel time
x
1: length
x
2: speed
x
3: stops
x
4: congestion
x
5: tr. lights
x
6: left turns
256
2107.51
30.30
2.10
42.43
225
0
284
2349.74
22.36
4.89
85.56
289
4
162
1248.51
19.33
9.27
85.91
81
1
448
2346.80
20.58
8.39
86.60
289
1
248
352.67
19.33
9.27
85.91
25
1
327
907.30
23.54
3.96
86.95
100
0
443.5
1093.29
22.01
5.44
88.66
169
0
294
348.35
23.68
3.81
89.33
25
0
125.5
1236.62
18.97
10.65
85.21
81
1
511.5
357.23
19.96
7.66
84.85
25
1
(c)
Airlines dataset
DepDelay
DayOfWeek
Distance
MeanVis
MeanWind
Thunderstorm
Precipitationmm
WindDirDegrees
Num
Dest
DepTime
0
3
588
24
14
0
12.7
333
18
SNA
2150
63
7
546
22
13
0
1.78
153
2
GEG
2256
143
5
919
24
18
0
9.14
308
27
MCI
2203
−4
6
599
22
16
0
11.68
161
23
SFO
2147
4
6
368
24
14
0
7.62
151
22
LAS
2159
19
5
188
20
35
0
1.02
170
23
IDA
2204
25
7
291
23
19
0
0
128
22
BOI
2200
1
6
585
17
10
0
6.6
144
25
SJC
2151
0
3
507
28
13
0
9.91
353
24
PHX
2150
38
2
590
28
23
0
0
176
7
LAX
2243Synthetic Data. We started with synthetic data in order to check how the partially linear regression performs on partially linear data and to compute the basic performance characteristics that depended on training and test set sizes. We took the following model: (23)y=0.5x1+x2sin⁡x2+ε,where x1 and x2 were independently uniformly distributed in the interval [0;1000] and ε~N(0;50). The dependence on x2 was clearly nonlinear and strictly fluctuating.Hanover Traffic Data. In [25], we simulated a traffic network in the southern part of Hanover, Germany, on the base of real traffic data. In this study, we used this simulation data as a dataset. The network contained three parallel and five perpendicular streets, which formed 15 intersections with a flow of approximately 5000 vehicles per hour. For our experiments, 6 variables were used: y travel time (min), x1 length of the route (km), x2 average speed in the system (km/h), x3 average number of stops in the system (units/min), x4 congestion level of the flow (veh/h), x5 traffic lights in the route (units), and x6 left turns in the route (units).For the Hanover traffic data, we solved the problem of travel time predictions. We did not filter the dataset and instead used the data in the original form. Principally, the analysis of outliers allows deleting suspicious observations to obtain more accurate results; however, some important information can be lost [26].Taking different subsets of variables, we found that the following variable assignment to linear and kernel parts of PLM is optimal:(i)
Linear partU: x4, x6(ii)
Kernel partT: x1, x2, x3, x5Airlines Data. The data consists of flight arrival and departure details for all commercial flights within the USA, from October 1987 to April 2008 [27]. This is a large dataset: there are nearly 120 million records in total, taking up 12 gigabytes. Every row in the dataset includes 29 variables. This data was used in various studies for analyzing the efficiency of methods proposed for big data processing, including regression [28]. In order to complement this data and to obtain a better prediction, we added weather average daily information, including daily temperatures (min/max), wind speed, snow conditions, and precipitation, which is freely available from the site https://www.wunderground.com/. This provided an additional 22 factors for each of the 731 days. The airlines and weather datasets were joined on the corresponding date.For this data, we aimed to solve the problem of the departure delay prediction, which corresponded to the DepDelay column of data.For test purposes, we selected the Salt Lake City International Airport (SLC). Our experiments showed that construction of a model for several airports resulted in poor results; this required special clustering [29] and could be the subject of future research.Therefore, we selected two years (1995 and 1996) for our analysis. This yielded approximately 170,000 records.An additional factor, which was added to this data, was the number of flights 30 minutes before and 30 minutes after the specific flight.The initial analysis showed the heterogeneous structure of this data. Clustering showed that two variables are the most important for separating the data: departure time and travel distance. A very promising cluster with good prediction potential was short late flights (DepTime ≥ 21:45 and Distance ≤ 1000 Km). They could provide relatively good predictions; however, the distribution of delays did not significantly differ from the original dataset. This cluster contained approximately 13,000 records.In subsequent experiments, we used subsets from this data in order to demonstrate the influence of dataset sizes on the prediction quality.For the PLM algorithm, the first important issue was how to divide the variables for the linear and kernel parts of the regression. Taking different subsets of variables and including/excluding variables one by one, we found 10 most significant variables and the following optimal subsets:(i)
Linear partU: distance of the flight (Distance), average visibility distance (MeanVis), average wind speed (MeanWind), average precipitation (Precipitationmm), wind direction (WindDirDegrees), number of flights in 30-minute interval (Num), and departure time (DepTime)(ii)
Kernel partT: day of the week (DayOfWeek), thunderstorm (0 or 1), and destination (Dest)Table2 presents data fragments of 10 random records from each training dataset.


## 6. Experimental Framework and Analysis

### 6.1. Accuracy Experiments

We compared the goodness-of-fit metric (R2) of the partially linear, linear, and kernel regression for the datasets by varying the size of the training dataset. Note that the accuracy did not depend on the size of the test set (which was taken equal to 1000). The results are presented in Figures 4, 5, and 6.Figure 4
Forecast quality dependence on training set size for synthetic data.Figure 5
Forecast quality dependence on training set size for traffic data.Figure 6
Forecast quality dependence on training set size for airlines data.We observed very different results. For synthetic data, one variable was linear by definition and another one was nonlinear; the partially linear model was preferable as it producedR2 with a value of 0.95 against 0.12 for both linear and kernel models. For the airlines dataset, partially linear model was also preferable, but the difference was not so significant. In contrast, for the Hanover data, the kernel model was preferable compared with the partially linear one starting from some point. One possible explanation is that the dimension of traffic data was less than airlines data, so the kernel model worked better when it had sufficient data.


### 6.2. Scalability Experiments

We compared the speed (execution time) of the partially linear, linear, and kernel regression for the datasets by varying the size of training and test datasets. Note that both sizes of training and test datasets influenced the execution time. The results for airlines data are presented in Figures7 and 8. Other datasets produced similar results.Figure 7
Execution time dependence on training set size for airlines data.Figure 8
Execution time dependence on test set size for airlines data.For the partially linear regression, we could see quadratic relationship between execution time and the size of the training set and a linear dependence of execution time from the size of the test set. These results could be easily interpreted, because the computation ofU~ and Y~ (steps (9) and (10) of PLM training, Figure 2) required a smoother matrix of size n×n, where n is the size of the training dataset. On the other hand, the test set participated in the forecasting step only, and the complexity had a linear relationship with its size. For kernel and linear regressions, the relationship with execution time was linear for both training and test set sizes.Next, we demonstrated how much resources (execution time) should be spent to reach some quality level (R2) for the partially linear regression model. The results for synthetic data are presented in Figure 9. This graph was constructed by fixing the test set size to 900, executing the algorithm for different training set sizes, obtaining the corresponding execution time and accuracy, and plotting them on the graph.Figure 9
Forecast quality dependence on execution time of PLM algorithm for synthetic data.We could see relatively fast growth at the beginning, but it slowed towards the end, and successive execution time investments did not increase the goodness of fit,R2.


### 6.3. Speed-Up Experiments

Finally, we examined how the execution time changes with the number of available cores. The results for the Hanover traffic data are presented in Figure10 and the remaining datasets produced similar results.Figure 10
PLM algorithm execution time depending on the number of processing cores for traffic data.We could see that the execution time decreased until it reached a threshold of 5–10 cores and then slightly increased (this is true for the PLM and the kernel regression; for the linear regression, the minimum was reached with 2 cores). This is explained by the fact that data transfer among a large number of cores takes significantly more time than computations. This meant that SPARK still needed a better optimization mechanism for parallel task execution. A similar issue has been reported by other researchers in [30] for clustering techniques.


## 6.1. Accuracy Experiments

We compared the goodness-of-fit metric (R2) of the partially linear, linear, and kernel regression for the datasets by varying the size of the training dataset. Note that the accuracy did not depend on the size of the test set (which was taken equal to 1000). The results are presented in Figures 4, 5, and 6.Figure 4
Forecast quality dependence on training set size for synthetic data.Figure 5
Forecast quality dependence on training set size for traffic data.Figure 6
Forecast quality dependence on training set size for airlines data.We observed very different results. For synthetic data, one variable was linear by definition and another one was nonlinear; the partially linear model was preferable as it producedR2 with a value of 0.95 against 0.12 for both linear and kernel models. For the airlines dataset, partially linear model was also preferable, but the difference was not so significant. In contrast, for the Hanover data, the kernel model was preferable compared with the partially linear one starting from some point. One possible explanation is that the dimension of traffic data was less than airlines data, so the kernel model worked better when it had sufficient data.


## 6.2. Scalability Experiments

We compared the speed (execution time) of the partially linear, linear, and kernel regression for the datasets by varying the size of training and test datasets. Note that both sizes of training and test datasets influenced the execution time. The results for airlines data are presented in Figures7 and 8. Other datasets produced similar results.Figure 7
Execution time dependence on training set size for airlines data.Figure 8
Execution time dependence on test set size for airlines data.For the partially linear regression, we could see quadratic relationship between execution time and the size of the training set and a linear dependence of execution time from the size of the test set. These results could be easily interpreted, because the computation ofU~ and Y~ (steps (9) and (10) of PLM training, Figure 2) required a smoother matrix of size n×n, where n is the size of the training dataset. On the other hand, the test set participated in the forecasting step only, and the complexity had a linear relationship with its size. For kernel and linear regressions, the relationship with execution time was linear for both training and test set sizes.Next, we demonstrated how much resources (execution time) should be spent to reach some quality level (R2) for the partially linear regression model. The results for synthetic data are presented in Figure 9. This graph was constructed by fixing the test set size to 900, executing the algorithm for different training set sizes, obtaining the corresponding execution time and accuracy, and plotting them on the graph.Figure 9
Forecast quality dependence on execution time of PLM algorithm for synthetic data.We could see relatively fast growth at the beginning, but it slowed towards the end, and successive execution time investments did not increase the goodness of fit,R2.


## 6.3. Speed-Up Experiments

Finally, we examined how the execution time changes with the number of available cores. The results for the Hanover traffic data are presented in Figure10 and the remaining datasets produced similar results.Figure 10
PLM algorithm execution time depending on the number of processing cores for traffic data.We could see that the execution time decreased until it reached a threshold of 5–10 cores and then slightly increased (this is true for the PLM and the kernel regression; for the linear regression, the minimum was reached with 2 cores). This is explained by the fact that data transfer among a large number of cores takes significantly more time than computations. This meant that SPARK still needed a better optimization mechanism for parallel task execution. A similar issue has been reported by other researchers in [30] for clustering techniques.


## 7. Concluding Remarks

This paper presents distributed parallel versions of kernel-density-based and partially linear regression models, intended to process big datasets in a reasonable time. The algorithms deploy Apache SPARK, which is a well-known distributed computation framework. The algorithms were tested over three different datasets of approximately 10,000 records, which cannot be processed by a single computer in a reasonable time. Thus, it was tested over a cluster of 16 nodes. We conducted three kinds of experiments. First, in theAccuracy Experiments, the results indicated that they could not be well forecasted using the linear regression model. We conducted the experiments with a more common situation, when the structure of the data is not linear or partially linear. For all the datasets, (non)semiparametric models (kernel and PLM) showed better results, taking as an efficiency criterion coefficient of determination, R2. As discussed, kernel regression experiences problem with increasing the dimensionality, because it is difficult to find the points in the neighborhood of the specified point in big dimensions. In our experiments, benchmark data and real-world data had many variables and we showed that semiparametric models gave more accurate results. We also conducted experiments by increasing the training set to show that it resulted in increased accuracy. Next, in theScalability Experiments, we changed the sizes of training and test sets with the aim of analyzing the algorithms’ computation time with the same fixed level of parallelism (number of working nodes/cores). All the experiments showed that the training set influenced the time nonlinearly (at most quadratically), but the test set influenced the time linearly. Finally, in theSpeed-Up Experiments, our purpose was to show the importance of parallel realization of the algorithms to work with big datasets, taking into account the fact that nonparametric and semiparametric estimation methods are very computationally intensive. We demonstrated the feasibility of processing datasets of varying sizes that were otherwise not feasible to process with a single machine. An interesting aspect was that for each combination (dataset, algorithm) we could find the optimal amount of resources (number of cores) to minimize the algorithms execution time. For example, for the PLM regression of the airlines data, with the training set size equal to 2500 and test set size equal to 500, the optimal number of cores was 5 and with the same training set size and the test set size equal to 1000 the optimal number of cores was 9. After this optimal point, the execution time of the algorithm starts to increase. We could explain this phenomenon, as the distribution expenses in this case were more than the award from the parallel execution. Thus, we could conclude that it is important to find the optimal amount of the resources for each experiment.



---

*Source: 5134962-2017-03-08.xml*