The existing open-clustermembership determination algorithms are either prior dependent on some known parameters of clusters or are not automatable to large samples of clusters. In this paper, we present ML-MOC, a new machine-learning-based approach to identify likely members of open clusters using the Gaia DR2 data and no a priori information about cluster parameters. We use the k-nearest neighbour (kNN) algorithm and the Gaussian mixture model (GMM) on high-precision proper motions and parallax measurements from the Gaia DR2 data to determine the membership probabilities of individual sources down to G similar to 20 mag. To validate the developed method, we apply it to 15 open clusters: M67, NGC 2099, NGC 2141, NGC 2243, NGC 2539, NGC 6253, NGC 6405, NGC 6791, NGC 7044, NGC 7142, NGC 752, Blanco 1, Berkeley 18, IC 4651, and Hyades. These clusters differ in terms of their ages, distances, metallicities, and extinctions and cover a wide parameter space in proper motions and parallaxes with respect to the field population. The extracted members produce clean colour-magnitude diagrams and our astrometric parameters of the clusters are in good agreement with the values derived in previous work. The estimated degree of contamination in the extracted members ranges between 2 per cent and 12 per cent. The results show that ML-MOC is a reliable approach to segregate open-cluster members from field stars.