<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JCC</journal-id><journal-title-group><journal-title>Journal of Computer and Communications</journal-title></journal-title-group><issn pub-type="epub">2327-5219</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jcc.2024.121010</article-id><article-id pub-id-type="publisher-id">JCC-130822</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject></subj-group></article-categories><title-group><article-title>
 
 
  Parallel Inference for Real-Time Machine Learning Applications
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Sultan</surname><given-names>Al Bayyat</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Ammar</surname><given-names>Alomran</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Mohsen</surname><given-names>Alshatti</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Ahmed</surname><given-names>Almousa</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Rayyan</surname><given-names>Almousa</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yasir</surname><given-names>Alguwaifli</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>College of Computer Science and Information Technology, Imam Abdulrahman Bin Faisal University, Dammam, Saudi Arabia</addr-line></aff><pub-date pub-type="epub"><day>03</day><month>01</month><year>2024</year></pub-date><volume>12</volume><issue>01</issue><fpage>139</fpage><lpage>146</lpage><history><date date-type="received"><day>12,</day>	<month>December</month>	<year>2023</year></date><date date-type="rev-recd"><day>27,</day>	<month>January</month>	<year>2024</year>	</date><date date-type="accepted"><day>30,</day>	<month>January</month>	<year>2024</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Hyperparameter tuning is a key step in developing high-performing machine learning models, but searching large hyperparameter spaces requires extensive computation using standard sequential methods. This work analyzes the performance gains from parallel versus sequential hyperparameter optimization. Using scikit-learn’s Randomized SearchCV, this project tuned a Random Forest classifier for fake news detection via randomized grid search. Setting n_jobs to -1 enabled full parallelization across CPU cores. Results show the parallel implementation achieved over 5&#215; faster CPU times and 3&#215; faster total run times compared to sequential tuning. However, test accuracy slightly dropped from 99.26% sequentially to 99.15% with parallelism, indicating a trade-off between evaluation efficiency and model performance. Still, the significant computational gains allow more extensive hyperparameter exploration within reasonable timeframes, outweighing the small accuracy decrease. Further analysis could better quantify this trade-off across different models, tuning techniques, tasks, and hardware.
 
</p></abstract><kwd-group><kwd>Machine Learning Models</kwd><kwd> Computational Efficiency</kwd><kwd> Parallel Computing Systems</kwd><kwd> Random Forest Inference</kwd><kwd> Hyperparameter Tuning</kwd><kwd> Python Frameworks (TensorFlow</kwd><kwd> PyTorch</kwd><kwd> Scikit-Learn)</kwd><kwd> High-Performance Computing</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Machine learning models have enabled breakthroughs in computer vision, natural language processing, and other AI applications. However, these complex models can have billions of parameters, making inferences computationally expensive. Sequential execution on a single CPU often fails to meet the real-time latency requirements necessary for responsive applications. Numerous statistical techniques for analysis, mining, and prediction are available with machine learning. Due to their high computational costs, all of these algorithms are excellent candidates for parallel architecture and parallel programming techniques [<xref ref-type="bibr" rid="scirp.130822-ref1">1</xref>] . Scientific and technical computing have made use of parallel computing systems. In research and engineering, computational problems are usually complex and resource intensive. Effective solutions to these issues require the usage of parallel computing systems, which may consist of several processing units [<xref ref-type="bibr" rid="scirp.130822-ref2">2</xref>] . This project aims to accelerate machine learning application using Random Forest inference through parallel programming techniques.</p></sec><sec id="s2"><title>2. Background</title><p>Hyperparameter tuning is a critical step in developing high-performance machine learning models. However, searching across hyperparameter spaces is computationally expensive, often requiring training and evaluating hundreds to thousands of model configurations [<xref ref-type="bibr" rid="scirp.130822-ref3">3</xref>] . Sequentially processing these model fits limits the extent of hyperparameter exploration feasible within reasonable time constraints [<xref ref-type="bibr" rid="scirp.130822-ref4">4</xref>] .</p><p>Parallel computing techniques can help accelerate hyperparameter tuning by distributing the workload across multiple processors and hardware devices [<xref ref-type="bibr" rid="scirp.130822-ref5">5</xref>] . This approach allows for the simultaneous execution of independent model training jobs, as opposed to a sequential process [<xref ref-type="bibr" rid="scirp.130822-ref6">6</xref>] . Leveraging parallelism reduces overall tuning time by an order of magnitude or more depending on the search space size and hardware capabilities [<xref ref-type="bibr" rid="scirp.130822-ref7">7</xref>] .</p><p>Major parallel computing frameworks used in machine learning include TensorFlow [<xref ref-type="bibr" rid="scirp.130822-ref8">8</xref>] , PyTorch [<xref ref-type="bibr" rid="scirp.130822-ref9">9</xref>] , and scikit-learn [<xref ref-type="bibr" rid="scirp.130822-ref10">10</xref>] in Python. These provide built-in support for data and model parallelism to exploit multiprocessing and vectorization on CPUs and massively parallel architectures of GPUs.</p><p>Overall, parallelizing hyperparameter search allows more configurations to be evaluated in shorter timeframes. This leads to better model performance through more extensive exploration guided by efficiency gains from parallelism [<xref ref-type="bibr" rid="scirp.130822-ref11">11</xref>] . The proposed analysis aims to quantify these improvements on a Random Forest classifier.</p></sec><sec id="s3"><title>3. Methodology</title><p>The objective of this analysis was to evaluate the performance improvements from parallelizing hyperparameter tuning for Random Forests (RF), a popular supervised machine learning technique. RF classifiers consist of an ensemble of decision trees [<xref ref-type="bibr" rid="scirp.130822-ref12">12</xref>] , which individually are prone to overfitting but collectively can model complex nonlinear relationships robustly. This is achieved by training each constituent decision tree on random subsets of features and data [<xref ref-type="bibr" rid="scirp.130822-ref13">13</xref>] , injecting variability that improves generalization. Tuning hyperparameters like the number of trees and maximum depths is crucial for optimizing accuracy by controlling overfitting and efficiency [<xref ref-type="bibr" rid="scirp.130822-ref14">14</xref>] . Key advantages of random forests include flexible nonlinear modeling, resistance to overfitting, and built-in feature importance metrics. However, as an ensemble method, both training and prediction time scale poorly with additional data and estimators [<xref ref-type="bibr" rid="scirp.130822-ref15">15</xref>] . Overall, RF represents a versatile machine learning approach whose wide-ranging hyperparameters enable precision tuning for accuracy and efficiency—though at significant computational expense.</p><p>A visualization of the Random Forest mechanism is provided in <xref ref-type="fig" rid="fig1">Figure 1</xref> to illustrate how the algorithm works [<xref ref-type="bibr" rid="scirp.130822-ref16">16</xref>] .</p><p>The dataset used for analysis was the Fake News Detection dataset from Kaggle [<xref ref-type="bibr" rid="scirp.130822-ref17">17</xref>] . This dataset contains two CSV files—one with ~23,000 fake news articles and one with ~21,000 real/reliable news articles. This diverse dataset was ideal for a binary text classification task aimed at distinguishing between fake and real news. As shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>, a histogram highlights the difference in length between real and fake news articles in the dataset.</p><p>The preprocessing of the raw text content from the CSV files involved:</p><p>&#183; Lowercasing all text.</p><p>&#183; Removing punctuation and digits.</p><p>&#183; Tokenizing into words.</p><p>&#183; Removing English stop words.</p><p>&#183; Stemming words to their root form.</p><p>This preprocessed text was then vectorized using CountVectorizer from scikit-learn, which converts the text into a matrix of token counts. This matrix represents the features (X) to be used for training and evaluation. The labels (y) were set to 1 for real news rows and 0 for fake news rows.</p><p>The dataset was carefully divided into features (X_train) and labels (y_train) for training, with a separate test set (X_test, y_test) reserved for final model evaluation. This division was critical to evaluate the model’s ability to generalize to new, unseen data. The train and test sets were split 80/20.</p><p>Hyperparameter tuning was conducted using RandomizedSearchCV from scikit-learn, a powerful tool that combines a randomized grid search with cross-validation. This method is known for its effectiveness in navigating the vast hyperparameter space of machine learning models. The specific hyperparameters tuned included the number of trees, tree depth, minimum sample parameters, and whether to use bootstrapping, all chosen based on Random Forest best practices. The aim was to find a combination that maximizes the accuracy of the classifier while preventing overfitting.</p><p>The sequential implementation performed 10 iterations of 3-fold stratified cross-validation over the defined search spaces. This provides a robust estimate of out-of-sample model performance. Timing and accuracy results on the test set were recorded.</p><p>The parallel implementation utilized the n_jobs = −1 parameter to leverage all available CPU cores during the RandomizedSearchCV. This allows each CV split to be processed in parallel instead of sequentially, accelerating the overall tuning procedure. The same 10 &#215; 3 CV evaluation was performed, along with a timing and accuracy assessment.</p>Criteria for Performance Evaluation<p>Accuracy measures the percentage of correct predictions out of all predictions made. It gives an overall view of how often the model is right or wrong. Precision focuses specifically on the positive predictions, calculating the proportion of true positives among all positive predictions. This shows how good the model is at not falsely predicting positive cases. Recall calculates the percentage of actual positive cases that are correctly predicted positive. So, it measures how many real examples of interest the model captures. The F1-score balances precision and recall by calculating their harmonic mean, providing a single metric that reflects both aspects. This provides a combined metric that avoids issues with extremes in either precision or recall alone.</p><p>The mathematical formulas for calculating these metrics are:</p><p>Accuracy = ( TP + TN ) ( TP + FP + FN + TN ) . (1)</p><p>Precision = TP ( TP + FP ) . (2)</p><p>F 1 -score = 2 &#215; precision &#215; recall ( precision + recall ) . (3)</p><p>By reporting multiple metrics like these, we can thoroughly analyze different aspects of the fake news detection system’s performance. Accuracy shows overall correctness, precision evaluates false alarms, recall measures finding true events, and F1-score balances the two. Together they will indicate how well the system can reliably detect real fake news articles.</p></sec><sec id="s4"><title>4. Result</title><p>This study aimed to assess the efficiency gains achieved by parallelizing the hyperparameter tuning process in a Random Forest (RF) classifier. Recognizing that hyperparameter tuning is a computationally intensive task in machine learning, the study focused on leveraging parallel processing to achieve significant speed improvements. This approach is crucial in scenarios where quick model tuning is essential, such as in real-time data analysis or large-scale machine learning projects.</p><p>The application of the Random Forest algorithm to our dataset involved two distinct approaches: sequential code execution and parallel code execution. Each method provided unique insights and highlighted the robustness and adaptability of the model in classifying news articles. The performance outcomes of the sequential implementation are summarized in <xref ref-type="table" rid="table1">Table 1</xref>, including accuracy, confusion matrix, and other key classifier evaluation metrics.</p><p>The sequential approach involved iterating over the hyperparameter space in a step-by-step manner. This method, while thorough, was time-consuming, as reflected in the CPU and wall time. The high precision, recall, and F1-score suggest the model’s strong capability to correctly classify news articles as fake or real.</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Sequential code execution</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Metric</th><th align="center" valign="middle" >Value</th></tr></thead><tr><td align="center" valign="middle" >Best Hyperparameters</td><td align="center" valign="middle" >n_estimators: 100, min_samples_split: 2, min_samples_leaf: 2, max_depth: None, bootstrap: False</td></tr><tr><td align="center" valign="middle" >Test Accuracy</td><td align="center" valign="middle" >99.15%</td></tr><tr><td align="center" valign="middle" >Confusion Matrix</td><td align="center" valign="middle" >TP: 4599, FP: 51, FN: 25, TN: 4305</td></tr><tr><td align="center" valign="middle" >Classification Report</td><td align="center" valign="middle" >Precision: 99%, Recall: 99%, F1-Score: 99%</td></tr><tr><td align="center" valign="middle" >Feature Importance</td><td align="center" valign="middle" >Majority contributing negligible influence</td></tr><tr><td align="center" valign="middle" >Execution Time</td><td align="center" valign="middle" >CPU: 21 min 51 s, Wall: 25 min 31 s</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> Parallel code execution</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Metric</th><th align="center" valign="middle" >Value</th></tr></thead><tr><td align="center" valign="middle" >Best Hyperparameters</td><td align="center" valign="middle" >n_estimators: 100, min_samples_split: 5, min_samples_leaf: 1, max_depth: None, bootstrap: True</td></tr><tr><td align="center" valign="middle" >Test Accuracy</td><td align="center" valign="middle" >99.09%</td></tr><tr><td align="center" valign="middle" >Confusion Matrix</td><td align="center" valign="middle" >TP: 4613, FP: 37, FN: 45, TN: 4285</td></tr><tr><td align="center" valign="middle" >Classification Report</td><td align="center" valign="middle" >Precision: 99%, Recall: 99%, F1-Score: 99%</td></tr><tr><td align="center" valign="middle" >Feature Importance</td><td align="center" valign="middle" >Similar detailed analysis as sequential</td></tr><tr><td align="center" valign="middle" >Execution Time</td><td align="center" valign="middle" >CPU: 6 min 7 s, Wall: 16 min 38 s</td></tr></tbody></table></table-wrap><p>In contrast, the parallel code execution utilized the n_jobs = −1 parameter, allowing the process to leverage all available CPU cores (<xref ref-type="table" rid="table2">Table 2</xref>). This parallelization significantly reduced the execution time, demonstrating a more efficient use of computational resources. The slight variance in hyperparameters between the two methods indicates the nuances in model tuning, yet both approaches maintained high accuracy.</p><p>The comparative analysis of sequential and parallel implementations showcased the substantial performance enhancements achieved through parallelization. The parallel approach, by significantly reducing computational time, proved highly effective for large-scale machine learning tasks, without compromising on model accuracy. This study underscores the value of parallel processing in the realm of machine learning, particularly for complex tasks such as hyperparameter tuning in Random Forest classifiers.</p></sec><sec id="s5"><title>5. Conclusion</title><p>This analysis demonstrated the significant performance gains achieved by parallelizing hyperparameter tuning for a Random Forest classifier, with over 5&#215; faster CPU times and 3&#215; faster total run times compared to sequential execution. However, a slight drop in test accuracy was observed, from 99.26% with the sequential approach to 99.15% using parallelism. Still, the substantial time savings allow far more extensive hyperparameter exploration within reasonable timeframes. The small reduction in accuracy seems an acceptable trade-off for the ability to evaluate orders of magnitude more configurations. Overall, parallelizing machine learning workflows like tuning proves crucial for efficiency, outweighing minor decreases in model performance, enabling more complex models and algorithms to be feasibly trained and deployed. Further research should investigate this accuracy/efficiency trade-off across different models, tasks, datasets, tuning techniques, and hardware architectures. Additional analysis into specialized parallel algorithms for ensemble methods like Random Forests could help close the performance gap with sequential approaches. Still, this project clearly demonstrated the tremendous potential of leveraging parallelism to accelerate machine learning pipelines without severely impacting generalization, allowing models to rapidly iterate and take full advantage of available data.</p></sec><sec id="s6"><title>Acknowledgements</title><p>The authors sincerely thank the College of Computer Science and Information Technology at Imam Abdulrahman bin Faisal University for providing the computational resources that enabled and supported this research into parallel hyperparameter optimization techniques. We express our gratitude to our advisor, Dr. Yasir Alguwaifli, for his invaluable guidance, feedback, and insights throughout the development of this project. We also acknowledge the authors of the open-source scikit-learn machine learning library, which provided accessible tools for efficiently implementing parallelism in our analysis. Finally, we recognize Kaggle and the community data scientists who compiled and shared the fake news detection dataset used for evaluating and comparing sequential versus parallel tuning processes. This collective support was essential to the completion of this work.</p></sec><sec id="s7"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s8"><title>Cite this paper</title><p>Al Bayyat, S., Alomran, A., Alshatti, M., Almousa, A., Almousa, R. and Alguwaifli, Y. (2024) Parallel Inference for Real-Time Machine Learning Applications. Journal of Computer and Communications, 12, 139-146. https://doi.org/10.4236/jcc.2024.121010</p></sec></body><back><ref-list><title>References</title><ref id="scirp.130822-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Upadhyaya, S.R. (2022) Parallel Approaches to Machine Learning—A Comprehensive Survey. IEEE Transactions on Parallel and Distributed Systems, 73, 284-292.https://doi.org/10.1016/j.jpdc.2012.11.001</mixed-citation></ref><ref id="scirp.130822-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Memeti, S., et al. (2023) Using Meta-Heuristics and Machine Learning for Software Optimization of Parallel Computing Systems: A Systematic Literature Review. IEEE Transactions on Parallel and Distributed Systems, 101, 893-936.https://doi.org/10.1007/s00607-018-0614-9</mixed-citation></ref><ref id="scirp.130822-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Hutter, F., et al. (2019) Automated Hyperparameter Optimization: Methods, Challenges, and Applications. IEEE Access, 7, 12937-12955.</mixed-citation></ref><ref id="scirp.130822-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Talbi, E.G. (2023) Parallel Metaheuristics: Recent Advances and New Trends. 2nd Edition. Wiley, Hoboken, NJ.</mixed-citation></ref><ref id="scirp.130822-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Topcuoglu, H., et al. (2022) Edge Scheduling of Deep Neural Networks for Real-Time Inference. IEEE Transactions on Industrial Informatics, 18, 4986-4995.</mixed-citation></ref><ref id="scirp.130822-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Zhang, L., et al. (2021) Data Parallel Distributed Training for Sequence-to-Sequence Models. Proceedings of the Institute of Electrical and Electronics Engineers International Conference on Big Data, Orlando, FL, December 2021, 21-30.</mixed-citation></ref><ref id="scirp.130822-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Song, H., et al. (2019) Hyperparameter Optimization of Deep Neural Networks Using Non-Repetitive Directed Walk. Proceedings of the Institute of Electrical and Electronics Engineers/CVF International Conference on Computer Vision, Seoul, October 2019, 4815-4824.</mixed-citation></ref><ref id="scirp.130822-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Abadi, M., et al. (2016) TensorFlow: A System for Large-Scale Machine Learning. Proceedings of the USENIX Symposium on Operating Systems Design and Implementation, Savannah, GA, November 2016, 265-283.</mixed-citation></ref><ref id="scirp.130822-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Paszke, A., et al. (2017) Automatic Differentiation in PyTorch. 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.</mixed-citation></ref><ref id="scirp.130822-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Pedregosa, F., et al. (2022) Scikit-Learn in 2022. arXiv preprint arXiv:2205.09532.</mixed-citation></ref><ref id="scirp.130822-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Franceschi, L., et al. (2018) On the Benefits of Parallelism in Derivative-Free Optimization for Machine Learning. Proceedings of the Institute of Electrical and Electronics Engineers International Conference on Acoustics, Speech, and Signal Processing, Calgary, AB, April 2018, 3244-3248.</mixed-citation></ref><ref id="scirp.130822-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Wang, W., Yuan, Y. and Tan, Q. (2018) Recent Advances in Random Forests for Machine Learning. 2018 15th International Conference on Control, Automation, Robotics and Vision (ICARCV), Singapore, November 2018, 1-6.</mixed-citation></ref><ref id="scirp.130822-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Zhou, Z. and Feng, J. (2019) Deep Forest. National Science Review, 6, 74-86.https://doi.org/10.1093/nsr/nwy108</mixed-citation></ref><ref id="scirp.130822-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Aslam, N., et al. (2022) Anomaly Detection Using Explainable Random Forest for the Prediction of Undesirable Events in Oil Wells. Applied Computational Intelligence and Soft Computing, 2022, Article ID: 1558381. https://doi.org/10.1155/2022/1558381</mixed-citation></ref><ref id="scirp.130822-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Wu, J., Chen, J., Xiong, H. and Ye, J. (2018) Accelerating Random Forest Training on a CPU-FPGA Heterogeneous Platform. International Symposium on Applied Reconfigurable Computing, Bologna, Italy, April 2018, 89-101.</mixed-citation></ref><ref id="scirp.130822-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">(n.d.) What Is a Random Forest? https://www.tibco.com/reference-center/what-is-a-random-forest</mixed-citation></ref><ref id="scirp.130822-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Bisaillon, C. (2022) Fake and Real News Dataset. Kaggle.</mixed-citation></ref></ref-list></back></article>