Elasticsearch includes a GeoIP processor that can be used when ingesting data to get the GeoLocation for an IP address. Read more about GeoIP Processor
For machine learning, I will direct you to the Machine Learning Getting Started documentation. That should walk you through building your first machine learning job and you should be able to adapt that to your use case.