A cyber-physical system (CPS) is one of the key technologies of industry 4.0. It is an integrated system that merges computing, sensors, and actuators, controlled by computer-based algorithms that integrate people and cyberspace. However, CPS performance is limited by its computational complexity. Finding a way to implement CPS with reduced complexity while incorporating more efficient diagnostics, forecasting, and equipment health management in a real-time performance remains a challenge. Therefore, the study proposes an integrative machine-learning method to reduce the computational complexity and to improve the applicability as a virtual subsystem in the CPS environment. This study utilizes random forest (RF) and a time-series deep-learning model based on the long short-term memory (LSTM) networking to achieve real-time monitoring and to enable the faster corrective adjustment of machines. We propose a method in which a fault detection alarm is triggered well before a machine fails, enabling shop-floor engineers to adjust its parameters or perform maintenance to mitigate the impact of its shutdown. As demonstrated in two empirical studies, the proposed method outperforms other times-series techniques. Accuracy reaches 80% or higher 3 h prior to real-time shutdown in the first case, and a significant improvement in the life of the product (281%) during a particular process appears in the second case. The proposed method can be applied to other complex systems to boost the efficiency of machine utilization and productivity.