Closed jonas-he closed 7 years ago
is the weka.jar located in the data directory of the package? do you get the same error for the testPrediction.js script of the package
yes it is located in the data directory. I am not getting the same error:
$ node testPrediction.js
2016-12-25T22:45:41.731Z started prediction script, init DC
5199ms to construct shortcut table
Average timezones per 1° lat x 1° lng: 4.414128352490422
2016-12-25T22:45:50.733Z created training arff file
2016-12-25T22:45:50.733Z requesting http://localhost:8080/api/pokemon/sighting/t
s/2016-09-14T08:00:00.000Z/range/1d?token=I0TPIIpCLH8lR8iDrCMV
2016-12-25T22:45:50.851Z downloaded 10000 sightings from API
2016-12-25T22:45:50.852Z filtered data, new length 10000
2016-12-25T22:46:21.592Z train classifier model, arff file creation took 30859
java -classpath ./data/weka.jar -Xmx1024m weka.classifiers.meta.Vote -S 1 -B "we
ka.classifiers.lazy.IBk -K 100 -W 0 -A \"weka.core.neighboursearch.LinearNNSearc
h -A \\\"weka.core.EuclideanDistance -R first-last\\\"\"" -B "weka.classifiers.b
ayes.BayesNet -D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES
-E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5" -R PROD -no-cv
-v -classifications "weka.classifiers.evaluation.output.prediction.Null" -t C:\
Users\joniu\Desktop\PokeData\node_modules\predict-pokemon\data\trainingData.arff
-d C:\Users\joniu\Desktop\PokeData\node_modules\predict-pokemon\data\classifier
2.model
2016-12-25T22:46:21.599Z created classifier model, training took 30865
Error: no cooc data
2016-12-25T22:46:21.761Z prediction took 161
2016-12-25T22:46:23.815Z prediction took 1169
2016-12-25T22:46:23.816Z #pred: 81, thrsh: 0 - conf#1 0.507 - mean 0.507 - var 0
- dis 3
2016-12-25T22:46:25.331Z prediction took 1187
2016-12-25T22:46:25.331Z #pred: 81, thrsh: 0 - conf#1 0.579 - mean 0.57918518518
51852 - var 0 - dis 3
2016-12-25T22:46:26.859Z prediction took 1184
2016-12-25T22:46:26.859Z #pred: 81, thrsh: 0 - conf#1 0.588 - mean 0.58866666666
66673 - var 0 - dis 4
2016-12-25T22:46:28.396Z prediction took 1175
2016-12-25T22:46:28.396Z #pred: 81, thrsh: 0 - conf#1 0.422 - mean 0.42200000000
00002 - var 0 - dis 4
2016-12-25T22:46:29.971Z prediction took 1183
2016-12-25T22:46:29.971Z #pred: 81, thrsh: 0 - conf#1 0.421 - mean 0.42099999999
999954 - var 0 - dis 5
2016-12-25T22:46:31.483Z prediction took 1136
2016-12-25T22:46:31.483Z #pred: 81, thrsh: 0 - conf#1 0.421 - mean 0.42099999999
999954 - var 0 - dis 5
and so on...
@bensLine oh and please add "fstream": "^1.0.10"
to your package.json
, I think Aurel forgot it.
Thanks, that looks ok. Can you please post the snippet where you call the function including the require statement and the hierarchy of the files. like where is the .jar located and where is your script. Yes, I'll look into it.
this is my directory structure (should be like it installed from npm):
│ .npmignore
│ dataSet_creator.js
│ feature_config.json
│ getApiData.js
│ getApiDataTest.js
│ getDataDump.js
│ LICENSE
│ package.json
│ prediction.js
│ prediction_feature_config.json
│ README.md
│ testPrediction.js
│
├───arff
│ apiDataExtended.arff
│ apiDataMockup.arff
│
├───data
│ classifier.model
│ classifier2.model
│ population_density.csv
│ testData.arff
│ trainingData.arff
│ weka.jar
│
├───data_analysis
│ apiData.json
│ apiData_pokemon_occurrences_20160904.csv
│ apiData_witnessed_ntimes_20160904.png
│ data_stats.py
│ dummy.json
│ dummy_pokemon_occurrences_20160904.csv
│ dummy_witnessed_ntimes_20160904.png
│ gym locations europe.png
│ gym locations.png
│ plot_coordinates.py
│ pokemon locations - data dump.png
│ pokemon locations europe - data dump.png
│ pokestop locations europe.png
│ pokestop locations.png
│
├───feature_sources
│ api_features.js
│ co-occurrence_post-features.js
│ isPokemonId_features.js
│ place_features.js
│ poketype_features.js
│ population_density.js
│ s2_features.js
│ terrain_features.js
│ time_features.js
│ weather_clean.js
│ weather_for_testing.js
│
├───json
│ CachedWeather.json
│ CachedWeatherFor2400entries.json
│ GoodRespond.json
│ gyms.json
│ gym_groups.json
│ landcover.json
│ pokeDump_2_sorted.zip
│ pokemon_types.json
│ pokestops.json
│ pokestops.zip
│ pokestop_groups.json
│ pokestop_groups.zip
│
├───node_modules
│
└───scripts
createCellIdGroups.js
postinstall.js
sortDump.js
the snippet where we call your package is here:
"use strict";
const sighting = require('../stores/sighting');
const prediction = require('predict-pokemon');
prediction.predictor.url = "https://predictemall.online/api/pokemon/sighting";
...
getPrediction: function (req, res) {
logger.info('Get Pokemon predictions by search parameters');
prediction.predictor.predict(req.params.latitude, req.params.longitude, req.params.ts, function(success, limited, message) {
if(success === 1)
res.status(200).json({message: 'Success', limited: limited, data: message});
else
res.status(404).json({message: 'Failure', limited: limited, data: message});
});
}
@bensLine i just realized that your predict method returns a Promise and has no callback 🤕
so i added code to resolve the Promise (like in your test_prediction.js). Turns out the Promise fails with Error: no cooc data
@bensLine so I did some digging and found a reason for the java error. What I did:
test
)npm install predict-pokemon
(on windows you have to fix tzwhere bug)test/node_modules/predict-pokemon/prediction.js
to my local APInode testPrediction.js
from the folder test/node_modules/predict-pokemon
=> works, predictions are generated as shown in my previous commenttest/node_modules/predict-pokemon/testPrediction.js
to test/testPrediction.js
test/testPrediction.js
to var predictor = require('./node_modules/predict-pokemon/prediction.js').predictor;
node testPrediction.js
from the folder test
=> error in retrain comes up like in my opening comment
Conclusion: error seems to be happening when requiring the package from outside. Could be a path issue in java, but I´m not sure...great, thanks for the logs! Yes, it's a path issue. @Aurel-Roci please update the npm package again :) if the fix #83 is fine and merged
@jonas-he If you get the Error: no cooc data
it's ok. That basically means that the sighting data is not yet completely processed and hence a prediction cannot be made until it is completely processed. The processing with 10k sightings from the API will probably take several minuets.
Important: I added an init()
method to prediction.js
, which needs to be called once before the predict() method is used. Best call it after setting the URL and the other stuff.
i get this output when requesting a prediction: