A computer-implemented method for estimating wax or hydrate deposition in an oil well, the method comprising: generating a dataset by loading one or more sets of oil well historical sensor measurement data, each set of oil well historical sensor measurement data comprising measurements related to an attribute of the oil well, and one or more sets of oil well historical event data, each set of oil well historical event data comprising date and time duration related to events of the oil well; cleansing the generated dataset by identifying and removing measurements that are invalid in quality for modeling wax or hydrate deposition in the oil well; enriching the cleansed dataset by deriving one or more feature variables and corresponding values based on measurements of oil well sensor variables, whereby enriching adds the values of the one or more derived feature variables to the cleansed dataset; identifying groups of highly correlated inputs by performing cross-correlation analysis on the enriched dataset, each identified group of highly correlated inputs comprising one or more of: measurements of a subset of the sensor variables and values of derived feature variables in the cleansed and enriched dataset; identifying and labeling data clusters using a machine learning unsupervised data clustering algorithm, thereby generating a dataset containing normal data ranges and events data for model building; removing highly correlated sensors for oil well operation state identification; performing feature selection using one representative input from each identified group of highly correlated inputs and outputting results to a sub-dataset; determining normal data ranges and state conditions from clustered data; building partial least square models for operation state identification; identifying and labeling events from the built PLS models and thresholds; iteratively splitting the dataset into a training dataset and a testing dataset, building and training an oil well model using the training sub-dataset, evaluating quality of the model using the testing sub-dataset, and storing the model when a termination criterion is met; executing the built and trained oil well model to estimate wax or hydrate deposition in the oil well based on real-time oil sensor data. generating a dataset by loading one or more sets of oil well historical sensor measurement data, each set of oil well historical sensor measurement data comprising measurements related to an attribute of the oil well, and one or more sets of oil well historical event data, each set of oil well historical event data comprising date and time duration related to events of the oil well; cleansing the generated dataset by identifying and removing measurements that are invalid in quality for modeling wax or hydrate deposition in the oil well; enriching the cleansed dataset by deriving one or more feature variables and corresponding values based on measurements of oil well sensor variables, whereby enriching adds the values of the one or more derived feature variables to the cleansed dataset; identifying groups of highly correlated inputs by performing cross-correlation analysis on the enriched dataset, each identified group of highly correlated inputs comprising one or more of: measurements of a subset of the sensor variables and values of derived feature variables in the cleansed and enriched dataset; identifying and labeling data clusters using a machine learning unsupervised data clustering algorithm, thereby generating a dataset containing normal data ranges and events data for model building; removing highly correlated sensors for oil well operation state identification; performing feature selection using one representative input from each identified group of highly correlated inputs and outputting results to a sub-dataset; determining normal data ranges and state conditions from clustered data; building partial least square models for operation state identification; identifying and labeling events from the built PLS models and thresholds; iteratively splitting the dataset into a training dataset and a testing dataset, building and training an oil well model using the training sub-dataset, evaluating quality of the model using the testing sub-dataset, and storing the model when a termination criterion is met; executing the built and trained oil well model to estimate wax or hydrate deposition in the oil well based on real-time oil sensor data.