Abstract
With the emergence of the big data age, obtaining valuable knowledge from massive datasets efficiently and accurately is a critical challenge. This paper presents a Parallel Random Forest (PRF) algorithm optimized for the Apache Spark platform. PRF employs a hybrid optimization strategy combining data-parallel and task-parallel techniques. Key innovations include vertical data partitioning to minimize communication overhead, a data-multiplexing method using Data-Sampling-Index (DSI) tables to reduce data volume, and a task Directed Acyclic Graph (DAG) for efficient scheduling. Additionally, the algorithm incorporates dimension reduction via Gain Ratio and weighted voting based on Out-of-Bag accuracy to enhance performance on high-dimensional, noisy data. Experimental results demonstrate that PRF significantly outperforms Spark MLlib in terms of accuracy, execution time, and scalability.
Introduction
Random Forest (RF) is a powerhouse for big data classification, but scaling it effectively in cloud environments is difficult. Traditional implementations often struggle with two main issues: communication bottlenecks and data explosion. Standard "horizontal" data partitioning requires massive data shuffles across the network to calculate feature statistics. Furthermore, the "bootstrap" sampling method typically creates multiple copies of the dataset, causing the data volume to grow linearly with the number of trees. This paper introduces PRF, a parallelized RF implementation on Spark designed to overcome these limitations through a multi-layered optimization strategy.
Methods
Algorithmic Enhancements
Before parallelization, the core RF logic is improved to handle high-dimensional data. PRF uses a dimension-reduction approach based on the Gain Ratio (GR). Instead of purely random feature selection, it selects the top $k$ principal variables and adds $(m-k)$ random variables to maintain ensemble diversity. Additionally, a weighted voting mechanism is implemented where each tree's prediction is weighted by its Out-of-Bag (OOB) accuracy, ensuring more reliable trees have a greater influence on the final result.
Data-Parallel Optimization
PRF utilizes vertical data partitioning, where the dataset is split by feature columns rather than rows. This ensures that all data required for calculating the gain of a specific feature is local to a single node, minimizing network traffic during the tree construction process.
To solve the data explosion problem, PRF introduces a Data-Sampling-Index (DSI) table. Instead of copying data for each tree's bootstrap sample, the system stores a table of indices. Each node reuses the same local feature subsets, loading only the records specified by the DSI, which keeps the training data volume constant regardless of the number of trees.
Task-Parallel Optimization
The training process is modeled as a Directed Acyclic Graph (DAG) of tasks. PRF uses a dual-parallel approach, parallelizing both the construction of different trees and the calculation of different feature nodes within those trees.
By mapping these dependencies, Spark can invoke specialized schedulers—such as LocalScheduler for data-intensive feature calculations and ClusterScheduler for coordination-heavy node splitting—to balance the workload effectively.
Experimental Results
The algorithm was evaluated using large-scale datasets from the UCI Machine Learning Repository and real-world medical records, with sizes up to 2.0TB.
- Accuracy: PRF consistently outperformed Spark MLlib and standard RF. In some cases, PRF was 8.1% to 11.3% more accurate than Spark MLlib on large-scale datasets.
- Execution Time: As data size increased, PRF's speed advantage became more pronounced. For a 500GB dataset, PRF completed training in approximately 101 seconds, while Spark MLlib took 186 seconds.
- Scalability: PRF's data communication cost (shuffle write) was significantly lower than Spark MLlib's and grew much more slowly as the cluster size increased, demonstrating superior scalability.
Conclusion
The PRF algorithm provides a robust and efficient solution for big data classification on Spark. By combining vertical partitioning, DSI-based multiplexing, and a hybrid task-parallel approach, it achieves superior performance and accuracy compared to existing frameworks. Future work will focus on developing an incremental version of the algorithm for real-time data streams.
Summary updated