This project uses Google Maps API and machine learning to predict the city of a geo-coordinate.
-
Install requirements
pip install -r requirements.txt
-
Get API key
Get your own Google Maps API key and store it in
key.txt
. -
Coordinates
The scripts are used for geo-coordinates within
117.95 ~ 117.68 W
,33.76 ~ 33.63 N
, which is an area around Irvine, CA, United States.You may edit these values in
location.py
, however you won't be able to use downloaded data indata/
folder.
-
download.py
Download data using Google Maps API. See
python download.py --help
for details.Please be aware that if you use too many api calls Google may charge you. See pricing section in Google API documentations.
-
map.py
Generate a mapping of locations to their categories using your data. See
python map.py --help
for details.If
--binary
is specified, only two categories will be generated, and basic logical regression will be used in the next step. -
train.py
Train the model using data specified. See
python train.py --help
for details.If
--binary
is specified, basic logical regression will be used.If
--test
is specified, run a test with the trained model and display results. This test data should not be one of the data files used in training. -
predict.py
Predict the location of coordinates using the trained model. See
python predict.py --help
for detailsThe label file is used to associate category with location names in the output. For non-binary mode, you can simply use the map file. For binary mode, you can create a file with two lines:
0,Others 1,{City name}
-
draw.py
Plot a map using your data. See
python draw.py --help
for details.