Merge and stuff.

This commit is contained in:
Casper 2019-04-06 14:40:49 +02:00
parent 21fa94bade
commit 9bce7205d8
No known key found for this signature in database
GPG Key ID: 289CA03790535054
6 changed files with 30 additions and 11 deletions

View File

@ -12,6 +12,7 @@ source venv/bin/activate
echo Installing required Python packages echo Installing required Python packages
pip install -Ur requirements.txt pip install -Ur requirements.txt
function run() { function run() {
python -m nightr python -m nightr
} }

View File

@ -7,8 +7,8 @@ from typing import List
import requests_cache import requests_cache
from flask import Flask, jsonify from flask import Flask, jsonify
from strategies import dmi, steam, miloStrats from server.nightr.strategies import dmi, steam, miloStrats
import Context from server.nightr.util import Context
app = Flask(__name__) app = Flask(__name__)
@ -19,8 +19,8 @@ strategies = {
# name: (weight, probability function) # name: (weight, probability function)
"dmi": (0.5, dmi.probability), "dmi": (0.5, dmi.probability),
"steam": (1.0, steam.probability), "steam": (1.0, steam.probability),
"australia" : (0.5, miloStrats.australiaStrat), "australia": (1.0, miloStrats.australiaStrat),
"camera" : (0.5, miloStrats.camImgStrat), "camera": (1.0, miloStrats.camImgStrat),
} }
@ -49,6 +49,12 @@ def probabilities():
median = statistics.median(p["weighted_probability"] for p in predictions) median = statistics.median(p["weighted_probability"] for p in predictions)
night = mean > 0.5 night = mean > 0.5
# Invert if we're in Australia
if context.in_australia:
night = not night
for prediction in predictions:
prediction["night"] = not prediction["night"]
# Calculate contributions of predictions # Calculate contributions of predictions
consensus_weight_sum = sum(p["weight"] for p in predictions if p["night"] == night) consensus_weight_sum = sum(p["weight"] for p in predictions if p["night"] == night)
for prediction in predictions: for prediction in predictions:

View File

@ -1,6 +1,8 @@
import requests
from datetime import datetime
import time import time
from datetime import datetime
import requests
def main(): def main():
filename = "dotaplayers " + str(datetime.now()) + ".csv" filename = "dotaplayers " + str(datetime.now()) + ".csv"
@ -16,5 +18,6 @@ def main():
f.close() f.close()
time.sleep(100) time.sleep(100)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -1,6 +1,8 @@
from datetime import datetime
import cv2 import cv2
from datetime import datetime, timedelta
from pytz import timezone from pytz import timezone
from server.nightr.util import Context, Prediction from server.nightr.util import Context, Prediction

View File

@ -1,11 +1,15 @@
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import List, Tuple from typing import List, Dict
@dataclass @dataclass
class Context: class Context:
battery: float = 1.0 battery: float
coordinates: Tuple[float, float] = (0.0, 0.0) position: Dict[str, float] # {'latitude': '23.2583', 'longitude': '154.0417'}
# App settings
in_australia: bool = False
flat_earth: bool = False
@dataclass @dataclass

View File

@ -1,4 +1,7 @@
Flask==1.0.2 Flask==1.0.2
requests==2.21.0 requests==2.21.0
requests-cache==0.4.13 requests-cache==0.4.13
pytz pytz
beautifulsoup4
pandas
opencv-python