Oily sludge pyrolysis technology has the advantages of potential recovery of valuable resources and safe disposal of non-recoverable residues. However, experimentally determining the optimal pyrolysis operating conditions is time-consuming and expensive. In this study, a machine learning (ML) approach was developed to predict and optimize the oily sludge pyrolysis process. Among the six machine learning models, eXtreme Gradient Boosting (XGB) was found to have the best prediction results. A multi-task XGB model was then developed with oily sludge ultimate and proximate composition and pyrolysis operating conditions as the modeling inputs. The modeling results indicated that the sludge ash and hydrogen contents as well as the pyrolysis temperature are the most critical factors affecting pyrolysis process and its performance. The contribution of sludge ultimate composition to the pyrolysis performance is 42.5 %, followed by sludge proximate properties (35.8 %) and pyrolysis operating conditions (21.7 %). The multi-task XGB ML model achieved an average R