npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

predict-pokemon

v2.0.4

Published

npm-packages

Downloads

102

Readme

PredictPokemon-2

Join the chat at https://gitter.im/pokemongoers/PredictPokemon-2 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.

##Install

npm install predict-pokemon

##Usage

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}

Setup

Package parameters

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.

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. 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 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,
  "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.

Example feature source

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.

Feature config

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
        }
      ]
    }
  ]
}
Feature source

The config contains several feature sources, which can contain several features. A feature source needs to specify:

  • the relative path to the corresponding .js file
  • an arbitrary name
  • an enabled flag to indicate whether or not the features of the source should be included in the data set by specifying true or false.
  • a list of features.
Feature

A feature is defined by:

  • a unique key, which can only be used once in the whole config file
  • a type 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}
  • an 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.
Class key

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.

##Developers

Benjamin Strobel: [email protected]

Marcel Wagenländer: [email protected]

Matthias Bauer:

Siamion Karcheuski: [email protected]

Aurel Roci: [email protected]

##Licence

Copyright (c) 2015 [Developers] (https://github.com/PokemonGoers/PredictPokemon-2/graphs/contributors)

Licensed under the MIT License