Let's say the variations in log-in details for a given user is low, but any large variation from this would trigger your alert.
For example, compress each log-in detail into one dimension, and then create a log-in detail vector for each user.
Every time a user logs in, create this detail array and store it. If you have accumulated a large set of test data you can try running some ML routines.
So, we have a user and a set of log-in data corresponding to successful log-ins. We can now train a Support Vector Machine to recognize this users log-in pattern:
from sklearn import svm
# training data [[11.0, 2, 2], [11.3, 2, 2] ... etc]
train_data = my_training_data()
# create and fit the model
clf = svm.OneClassSVM()
and then, every time a new log-in even occurs, create a single log-in detail array and pass that past the SVM
if clf.predict(log_in_data) < 0:
print('log in ok')
if the SVM finds the new data point different from its training set then it will fire the alarm.
A good training set, there are many more ML techniques that may be better suited to your task but creating your training sets and training the routines would be the most significant.
If you have bad log-in attempts, you can add these to the training sets by using a more complex SVM which you train with good and bad log-ins. Instead of using an array of disparate 'location' values, you could find the Euclidean different log-ins and use that!
Thus, for more details on this, Machine Learning Course would be quite useful. Also, study the Couch Db Course to master the course.
Hope this answer helps you!