I am trying to predict crime rates and I have naively used lat and long as two separate factors (which seem to work well!). Are there any best practices for location as a factor?
If you are predicting crime rates in a certain region, we may use clustering to deduce useful information. In clustering, basically, we will try to group similar data points together and treat them as a single class. We can understand this with an instance.
We have various points ( Latitude and Longitude ) and each of them represents a certain type of crime. Even by mere observation, we can conclude that some specific types of crime occur in a particular region only. Basically, we are going to cluster such points which are in the vicinity of each other and belong to the same class ( kind ).
For example, an emergency call from an area ( with more cases of robbery ) arrives, the probability that the victim has also suffered from the robbery is more than any other crimes.
As we get more data, we can retrain our clustering algorithms to make more clusters and thereby increase efficiency.
In the past what better worked for me was encoding the location as a categorical variable with:
And then target encoding to change to a numerical feature:
It arises the problem of the granularity, but it can be modified:
You can specify an arbitrary precision when encoding. The precision determines the number of characters in the Geohash:
print 'Geohash for 42.6, -5.6:', Geohash.encode(42.6, -5.6, precision=5) Geohash for 42.6, -5.6: ezs42
It really depends on your dataset. There isnt a set of rules: xyz works always
To compare it with your problem I would advise you to find similiar datasets or problems on kaggle.
For example demographic-data could spark you some ideas how you can use geographical information.