Machine learning (ML) has been increasingly adopted to solve engineering problems with performance gauged by accuracy, efficiency, and security. Notably, blockchain technology (BT) has been added to ML when security is a particular concern. Nevertheless, there is a research gap that prevailing solutions focus primarily on data security using blockchain but ignore computational security, making the traditional ML process vulnerable to off-chain risks. Therefore, the research objective is to develop a novel ML on blockchain (MLOB) framework to ensure both the data and computational process security. The central tenet is to place them both on the blockchain, execute them as blockchain smart contracts, and protect the execution records on-chain. The framework is established by developing a prototype and further calibrated using a case study of industrial inspection. It is shown that the MLOB framework, compared with existing ML and BT isolated solutions, is superior in terms of security (successfully defending against corruption on six designed attack scenario), maintaining accuracy (0.01% difference with baseline), albeit with a slightly compromised efficiency (0.231 second latency increased). The key finding is MLOB can significantly enhances the computational security of engineering computing without increasing computing power demands. This finding can alleviate concerns regarding the computational resource requirements of ML–BT integration. With proper adaption, the MLOB framework can inform various novel solutions to achieve computational security in broader engineering challenges.