Predicting the viscosity of polymer nanocomposites (PNCs) is of critical importance as it governs a dominant role in PNCs processing and application. Machine learning (ML) algorithms, enabled by pre-existing experimental and computational data, have emerged as robust tools for the prediction of quantitative relationships between feature parameters and various physical properties of materials. In this work, we employed nonequilibrium molecular dynamics (NEMD) simulation with ML models to systematically investigate the viscosity of PNCs over a wide range of NPs loading, shear rates and temperature.With the increase in shear rates, shear thinning takes place as the value of viscosity decreases on the orders of magnitude. In addition, the NPs loading -dependence and T-dependence reduce to the extent that it is not visible at high shear rates. The value of viscosity for PNCs is proportional to NPs loading and inversely proportional to T below the intermediate shear rates. Using the obtained NEMD results, four machine learning models were trained to provides eective predictions for the viscosity. The extreme gradient boosting (XGBoost) model yields the best accuracy in viscosity prediction under complex conditions and is further used to evaluate feature importance. This quantitative structure-property relationship (QSPR) model used physical views to investigate the effect of process parameters, such as temperature, NPs loading and shear rates, on the viscosity of PNCs and paves the path for theoretically proposing reasonable parameters for successful processing.