<commit_before># PredictPokemon-2

[![Join the chat at https://gitter.im/pokemongoers/PredictPokemon-2](https://badges.gitter.im/pokemongoers/PredictPokemon-2.svg)](https://gitter.im/pokemongoers/PredictPokemon-2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
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.

## Setup
#### tzwhere bug
If you are running windows the script might get stuck in the `require('tzwhere')` call, due to an old version of *timezone* [tzwhere#13](https://github.com/mattbornski/tzwhere/issues/13).
To fix this modify the `package.json` of tzwhere, probably under the path `PredictPokemon\node_modules\tzwhere\package.json`.
- Set the timezone version under dependencies to `0.0.48`

```
  "dependencies": {
    ...
    "timezone": "0.0.48"
    ...
}
```

- delete the timezone folder in `PredictPokemon\node_modules\tzwhere\node_modules`
- cahnge directory to `PredictPokemon\node_modules\tzwhere`
- run `npm install`

done :)

## Implementation
### Data Set
#### Feature sources
The data set which is used for the prediction consists out of different features, which need to be extracted from the [raw API data](http://pokedata.c4e3f8c7.svc.dockerapp.io:65014/doc/#api-PokemonSighting-GetAllSightings) of Team A. To generate those features different feature sources are used. Each feature source provides different data, for example,
- one source extracts the S2 cell id's from the raw API data by using latitude and longitude
- whereas another extracts local time, hour of the day and other time-related features from the timestamp of the API data
- another source uses location and time to extract weather related features and so on...

##### getFeatures Method
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:

###### pokeEntry

```
{
  "_id": "57c92f926ffa1ace02c48f04",
  "source": "POKESNIPER",
  "appearedOn": "2016-09-02T07:53:21.000Z",
  "__v": 0,<commit_msg>fixed typo in readme<commit_after># PredictPokemon-2

[![Join the chat at https://gitter.im/pokemongoers/PredictPokemon-2](https://badges.gitter.im/pokemongoers/PredictPokemon-2.svg)](https://gitter.im/pokemongoers/PredictPokemon-2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
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.

## Setup
#### tzwhere bug
If you are running windows the script might get stuck in the `require('tzwhere')` call, due to an old version of *timezone* [tzwhere#13](https://github.com/mattbornski/tzwhere/issues/13).
To fix this modify the `package.json` of tzwhere, probably under the path `PredictPokemon\node_modules\tzwhere\package.json`.
- Set the timezone version under dependencies to `0.0.48`

```
  "dependencies": {
    ...
    "timezone": "0.0.48"
    ...
}
```

- delete the timezone folder in `PredictPokemon\node_modules\tzwhere\node_modules`
- change directory to `PredictPokemon\node_modules\tzwhere`
- run `npm install`

done :)

## Implementation
### Data Set
#### Feature sources
The data set which is used for the prediction consists out of different features, which need to be extracted from the [raw API data](http://pokedata.c4e3f8c7.svc.dockerapp.io:65014/doc/#api-PokemonSighting-GetAllSightings) of Team A. To generate those features different feature sources are used. Each feature source provides different data, for example,
- one source extracts the S2 cell id's from the raw API data by using latitude and longitude
- whereas another extracts local time, hour of the day and other time-related features from the timestamp of the API data
- another source uses location and time to extract weather related features and so on...

##### getFeatures Method
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:

###### pokeEntry

```
{
  "_id": "57c92f926ffa1ace02c48f04",
  "source": "POKESNIPER",
  "appearedOn": "2016-09-02T07:53:21.000Z",
  "__v": 0,
{'fraction_non_alphanumeric': 0.09740932642487046, 'fraction_numerical': 0.024041450777202072, 'mean_word_length': 4.786570743405276, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2288285', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1449, 'n_words': 558}