In this project we will apply machine learning to establish the TLN (Time, Location and Name - that is where pokemons will appear, at what date and time, and which Pokemon will it be) prediction in Pokemon Go.
npm install predict-pokemon
First run this to unzip files: var unzip = require('./node_modules/predict-pokemon/unzip.js'); unzip.unzipFiles();
predict(lat, lng, timestamp)
The predictions will available as an array of objects
{"pokemonId":"16","confidence":"0.242","latitude":11.6088567,"longitude":48.1679286}
Here is a list of parameters which can be changed from outside the package:
predictor.url = http://pokedata.c4e3f8c7.svc.dockerapp.io:65014/api/pokemon/sighting';
the base url to the pokeData API for sightings: http:// ... /api/pokemon/sighting, including 'api/pokemon/sighting'.
predictor.threshold = 0.1;
the threshold for predictions. if the confidence of a prediction is bellow the threshold it will be ignored. range 0..1.
predictor.useCurrentDate = true;
if true the current date will be used to retrieve data from the API. otherwise the requestDate
bellow is used.
predictor.requestDate = new Date('2016-09-14T08:00:00Z');
if useCurrentDate
is false this date will be used to retrieve data from the API.
predictor.gridDistance = 0.25;
the grid distance in km. the predictor returns 81 grids and this parameter defines the distance from one grid center to the center of an horizontal or vertically adjacent grid.
If you are running windows the script might get stuck in the require('tzwhere')
call, due to an old version of timezone tzwhere#13.
To fix this modify the package.json
of tzwhere, probably under the path PredictPokemon\node_modules\tzwhere\package.json
.
0.0.48
"dependencies": {
...
"timezone": "0.0.48"
...
}
PredictPokemon\node_modules\tzwhere\node_modules
PredictPokemon\node_modules\tzwhere
npm install
done :)
The data set which is used for the prediction consists out of different features, which need to be extracted from the raw API data of Team A. To generate those features different feature sources are used. Each feature source provides different data, for example,
To handle all feature sources in a generic way they have to provide the getFeatures(keys, pokeEntry)
method. The method receives an array of unique keys which refer to features, e.g. the hourOfTheDay
feature, and it receives a pokeEntry, which represents the JSON object that Team A uses to describe the sighting of a Pokemon. The pokeEntry provides the following data:
{
"_id": "57c92f926ffa1ace02c48f04",
"source": "POKESNIPER",
"appearedOn": "2016-09-02T07:53:21.000Z",
"__v": 0,
"pokemonId": 73,
"latitude": -33.871224,
"longitude": 151.199544,
"appearedLocalTime": "2016-09-02T17:53:21.000Z"
}
The latitude and longitude are actually added additionally, to allow easy access. Team A sends them in a nested JSON object within the pokeEntry. The same goes for appearedLocalTime.
Here is an example how a feature source has to be implemented in order to work with the rest:
// feature_sources/time_features.js
(function (exports) {
var module = exports.module = {};
module.getFeatures = function (keys, pokeEntry) {
var values = {};
keys.forEach(function (key) {
if (key === "hourOfTheDay") {
values[key] = parseHourOfTheDay(pokeEntry.appearedOn);
}
else {
console.log("The key " + key + " is not handled by the time feature source.");
throw "UnknownFeatureKey";
}
}
return values;
});
})('undefined' !== typeof module ? module.exports : window);
The source has to specify the module
variable and implement module.getFeatures = function (keys, pokeEntry)
so that it can be used by dataSet_creator.js.
The source has to return an object as result, which maps a value to every key. The implementation of the function depends on the features to extract.
The keys which are used in the getFeatures
method have to be specified in the feature_config.json
file, which looks like this:
{
"classKey": "pokemonId",
"feature_sources": [
{
"name": "API Features",
"path": "./feature_sources/api_features.js",
"enabled": true,
"features": [
{
"key": "pokemonId",
"type": "numeric",
"enabled": true
}
]
},
{
"name": "Time Features",
"path": "./feature_sources/time_features.js",
"enabled": true,
"features": [
{
"key": "hourOfTheDay",
"type": "nominal",
"enabled": true
}
]
}
]
}
The config contains several feature sources, which can contain several features. A feature source needs to specify:
path
to the corresponding .js filename
enabled
flag to indicate whether or not the features of the source should be included in the data set by specifying true
or false
.features
.A feature is defined by:
key
, which can only be used once in the whole config filetype
which corresponds to the attribute type of Weka, e.g. numeric, string or nominal. If nominal is provided the script creates a nominal list with all distinct values that exist in the data set. For example: @ATTRIBUTE source {POKESNIPER, POKERADAR, TWITTER}
enabled
flag to indicate individually whether or not the feature should be included in the data set, by specifying true
or false
. The source must be enabled for that.The classKey
defines which key will be used as classLabel when an .arff file is generated. The classKey
has to correspond to a feature key in the configuration. If a feature key corresponds to the classKey
it does not matter if the enabled
flag is set or not. The script generates automatically a nominal list with all distinct values that exist in the data set for that key.
Benjamin Strobel: benjamin.strobel@tum.de
Marcel Wagenländer: marcel.wagenlaender@tum.de
Matthias Bauer:
Siamion Karcheuski: semioniy@mail.ru
Aurel Roci: aurel_2798@hotmail.com
Copyright (c) 2015 [Developers] (https://github.com/PokemonGoers/PredictPokemon-2/graphs/contributors)
Licensed under the MIT License