From 9997aca958821ab83c281d99793973fbb71cd2db Mon Sep 17 00:00:00 2001 From: Milo Date: Sat, 6 Apr 2019 17:40:51 +0200 Subject: [PATCH] added weights for milo strats --- server/activate.sh | 1 - server/nightr/strategies/miloStrats.py | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/activate.sh b/server/activate.sh index cda886f..81ffbe1 100755 --- a/server/activate.sh +++ b/server/activate.sh @@ -12,7 +12,6 @@ source venv/bin/activate echo Installing required Python packages pip install -Ur requirements.txt - function run() { python -m nightr } diff --git a/server/nightr/strategies/miloStrats.py b/server/nightr/strategies/miloStrats.py index be105e5..3b08314 100644 --- a/server/nightr/strategies/miloStrats.py +++ b/server/nightr/strategies/miloStrats.py @@ -14,8 +14,9 @@ def camImgStrat(context : Context) -> Prediction: """ img = cv2.imread(str(Path(__file__).parent.joinpath("night.jpg")), 0) average = img.mean(axis=0).mean(axis=0) - print(average) p = Prediction() + p.weight = 0.7 + if average < 100: p.probability = 1.0 p.reasons.append('Image was dark') @@ -33,6 +34,7 @@ def australiaStrat(context : Context) -> Prediction: t = datetime.now().astimezone(australia) hour = t.hour p = Prediction() + if hour > 22 or hour < 6: p.probability = 0.0 p.reasons.append('It\'s night-time in Australia') @@ -55,9 +57,8 @@ def tv2newsStrat(context : Context) -> Prediction: avg_delta += d avg_timestamp = avg_delta // len(delta_times) // 60 p = Prediction() - print('average time between articles on tv2:', avg_timestamp, 'minutes') + p.weight = 0.7 p.probability = 1.0 if avg_timestamp > 50 else 0.0 p.reasons.append('There were ' + ('few' if avg_timestamp > 50 else 'many') + ' recent articles on TV2 News') - print(p.reasons[0]) return p