improved graphs with histogram and details
This commit is contained in:
parent
7a62e19b7f
commit
a878d142bd
25 changed files with 240 additions and 128 deletions
|
@ -4,4 +4,6 @@ PyQt6-WebEngine
|
||||||
nextcord~=2.6.0
|
nextcord~=2.6.0
|
||||||
requests~=2.31.0
|
requests~=2.31.0
|
||||||
|
|
||||||
cx_freeze
|
cx_freeze
|
||||||
|
matplotlib~=3.8.2
|
||||||
|
numpy~=1.26.3
|
|
@ -1,16 +1,11 @@
|
||||||
from collections import Counter
|
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
ages_data = list(map(extract.age.extract, datas))
|
x = list(map(extract.age.extract, datas))
|
||||||
|
|
||||||
counter = Counter(ages_data)
|
|
||||||
x = list(counter.keys())
|
|
||||||
y = list(counter.values())
|
|
||||||
|
|
||||||
# prepare plotting
|
# prepare plotting
|
||||||
figure: plt.Figure = plt.figure()
|
figure: plt.Figure = plt.figure()
|
||||||
|
@ -18,6 +13,7 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre de personne par âge")
|
axes.set_title("Nombre de personne par âge")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
bins = np.arange(min(x), max(x), 1)
|
||||||
|
axes.hist(x, bins=bins, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -6,7 +6,7 @@ import numpy as np
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
ages_completion: dict[int, int] = defaultdict(lambda: 0)
|
ages_completion: dict[int, int] = defaultdict(lambda: 0)
|
||||||
ages_count: dict[int, int] = defaultdict(lambda: 0)
|
ages_count: dict[int, int] = defaultdict(lambda: 0)
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre moyen de mission complété par âge")
|
axes.set_title("Nombre moyen de mission complété par âge")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
bins = np.arange(min(x), max(x), 1)
|
||||||
|
axes.hist(x, bins, weights=y, edgecolor="black")
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
experience_completion: dict[str, int] = {"yes": 0, "mixed": 0, "no": 0}
|
experience_completion: dict[str, int] = dict.fromkeys(ressource.experience.choices, 0)
|
||||||
experience_count: dict[str, int] = {"yes": 0, "mixed": 0, "no": 0}
|
experience_count: dict[str, int] = dict.fromkeys(ressource.experience.choices, 0)
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
experience = extract.experience.extract(data)
|
experience = extract.experience.extract(data)
|
||||||
|
@ -32,6 +32,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre moyen de mission complété par expérience")
|
axes.set_title("Nombre moyen de mission complété par expérience")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
39
tools/statistics/analyse/completion_per_language.py
Normal file
39
tools/statistics/analyse/completion_per_language.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
|
languages_completion: dict[str, int] = defaultdict(lambda: 0)
|
||||||
|
languages_count: dict[str, int] = defaultdict(lambda: 0)
|
||||||
|
|
||||||
|
for data in datas:
|
||||||
|
language = extract.language.extract(data)
|
||||||
|
languages_count[language] += 1
|
||||||
|
|
||||||
|
for survey, survey_data in data["surveys"].items():
|
||||||
|
# only scan survey mission
|
||||||
|
if not survey.startswith("mission-"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if extract.mission_completed.extract(data, survey):
|
||||||
|
languages_completion[language] += 1
|
||||||
|
|
||||||
|
x = list(languages_completion.keys())
|
||||||
|
y = (
|
||||||
|
np.array(list(languages_completion.values()))
|
||||||
|
/ np.array(list(languages_count.values()))
|
||||||
|
)
|
||||||
|
|
||||||
|
# prepare plotting
|
||||||
|
figure: plt.Figure = plt.figure()
|
||||||
|
axes = figure.add_subplot(1, 1, 1)
|
||||||
|
axes.set_title("Nombre moyen de mission complété par langue")
|
||||||
|
|
||||||
|
# bar chart
|
||||||
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
|
return figure
|
|
@ -1,23 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
completions: dict[str] = {
|
completions: dict[str] = dict.fromkeys(ressource.mission.choices, 0)
|
||||||
"mission-language": 0,
|
|
||||||
"mission-price": 0,
|
|
||||||
"mission-community-hub": 0,
|
|
||||||
"mission-game-page": 0,
|
|
||||||
"mission-game-dlc": 0,
|
|
||||||
"mission-actuality-new": 0,
|
|
||||||
"mission-profile": 0,
|
|
||||||
"mission-game-discussion": 0,
|
|
||||||
"mission-gift-card": 0,
|
|
||||||
"mission-workshop": 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
# NOTE : séparé avant / après grosse mise à jour pour carte cadeau ?
|
# TODO : couleur par mission
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
for survey in data["surveys"].keys():
|
for survey in data["surveys"].keys():
|
||||||
|
@ -37,8 +26,8 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre de personne ayant réussi par mission")
|
axes.set_title("Nombre de personne ayant réussi par mission")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
axes.set_xticks(x)
|
axes.set_xticks(x)
|
||||||
axes.set_xticklabels(x, rotation=45)
|
axes.set_xticklabels(x, rotation=45)
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
usage_completion: dict[str, int] = {"always": 0, "often": 0, "sometime": 0, "rarely": 0, "never": 0}
|
usage_completion: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
|
||||||
usage_count: dict[str, int] = {"always": 0, "often": 0, "sometime": 0, "rarely": 0, "never": 0}
|
usage_count: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
usage = next(filter(
|
usage = next(filter(
|
||||||
|
@ -36,6 +36,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre moyen de mission complété par niveau")
|
axes.set_title("Nombre moyen de mission complété par niveau")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -6,11 +6,11 @@ import numpy as np
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
ages_duration: dict[int, int] = defaultdict(lambda: 0)
|
ages_duration: dict[int, int] = defaultdict(lambda: 0)
|
||||||
ages_count: dict[int, int] = defaultdict(lambda: 0)
|
ages_count: dict[int, int] = defaultdict(lambda: 0)
|
||||||
|
|
||||||
# TODO: faire des tranches d'âges ?
|
# TODO: affichage en minutes ?
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
age = extract.age.extract(data)
|
age = extract.age.extract(data)
|
||||||
|
@ -35,6 +35,7 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Temps moyen passé par âge")
|
axes.set_title("Temps moyen passé par âge")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
bins = np.arange(min(x), max(x), 1)
|
||||||
|
axes.hist(x, bins, weights=y, edgecolor="black")
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
experience_duration: dict[str, int] = {"yes": 0, "mixed": 0, "no": 0}
|
experience_duration: dict[str, int] = dict.fromkeys(ressource.experience.choices, 0)
|
||||||
experience_count: dict[str, int] = {"yes": 0, "mixed": 0, "no": 0}
|
experience_count: dict[str, int] = dict.fromkeys(ressource.experience.choices, 0)
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
experience = extract.experience.extract(data)
|
experience = extract.experience.extract(data)
|
||||||
|
@ -32,6 +32,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Temps moyen passé par expérience")
|
axes.set_title("Temps moyen passé par expérience")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
38
tools/statistics/analyse/duration_per_language.py
Normal file
38
tools/statistics/analyse/duration_per_language.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
|
languages_duration: dict[str, int] = defaultdict(lambda: 0)
|
||||||
|
languages_count: dict[str, int] = defaultdict(lambda: 0)
|
||||||
|
|
||||||
|
for data in datas:
|
||||||
|
language = extract.language.extract(data)
|
||||||
|
languages_count[language] += 1
|
||||||
|
|
||||||
|
for survey in data["surveys"].keys():
|
||||||
|
# only scan survey mission
|
||||||
|
if not survey.startswith("mission-"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
languages_duration[language] += extract.mission_duration.extract(data, survey)
|
||||||
|
|
||||||
|
x = list(languages_duration.keys())
|
||||||
|
y = (
|
||||||
|
np.array(list(languages_duration.values()))
|
||||||
|
/ np.array(list(languages_count.values()))
|
||||||
|
)
|
||||||
|
|
||||||
|
# prepare plotting
|
||||||
|
figure: plt.Figure = plt.figure()
|
||||||
|
axes = figure.add_subplot(1, 1, 1)
|
||||||
|
axes.set_title("Temps moyen passé par langue")
|
||||||
|
|
||||||
|
# bar chart
|
||||||
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
|
return figure
|
|
@ -1,25 +1,14 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
durations: dict[str] = {
|
durations: dict[str] = dict.fromkeys(ressource.mission.choices, 0)
|
||||||
"mission-language": 0,
|
|
||||||
"mission-price": 0,
|
|
||||||
"mission-community-hub": 0,
|
|
||||||
"mission-game-page": 0,
|
|
||||||
"mission-game-dlc": 0,
|
|
||||||
"mission-actuality-new": 0,
|
|
||||||
"mission-profile": 0,
|
|
||||||
"mission-game-discussion": 0,
|
|
||||||
"mission-gift-card": 0,
|
|
||||||
"mission-workshop": 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
# NOTE : séparé avant / après grosse mise à jour pour carte cadeau ?
|
# TODO : marqué en rouge la durée d'abandon ?
|
||||||
# NOTE : marqué en rouge la durée d'abandon ?
|
# TODO : couleur par mission
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
for survey in data["surveys"].keys():
|
for survey in data["surveys"].keys():
|
||||||
|
@ -38,8 +27,8 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Temps moyen passé par test")
|
axes.set_title("Temps moyen passé par test")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
axes.set_xticks(x)
|
axes.set_xticks(x)
|
||||||
axes.set_xticklabels(x, rotation=45)
|
axes.set_xticklabels(x, rotation=45)
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
usage_completion: dict[str, int] = {"always": 0, "often": 0, "sometime": 0, "rarely": 0, "never": 0}
|
usage_completion: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
|
||||||
usage_count: dict[str, int] = {"always": 0, "often": 0, "sometime": 0, "rarely": 0, "never": 0}
|
usage_count: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
|
||||||
|
|
||||||
# TODO: faire des tranches d'âges ?
|
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
usage = extract.usage.extract(data)
|
usage = extract.usage.extract(data)
|
||||||
|
@ -33,6 +31,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Temps moyen passé par niveau")
|
axes.set_title("Temps moyen passé par niveau")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -2,11 +2,11 @@ from collections import Counter
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
experiences: dict[str, int] = {"yes": 0, "mixed": 0, "no": 0}
|
experiences: dict[str, int] = dict.fromkeys(ressource.experience.choices, 0)
|
||||||
for data in datas:
|
for data in datas:
|
||||||
experience = extract.experience.extract(data)
|
experience = extract.experience.extract(data)
|
||||||
experiences[experience] += 1
|
experiences[experience] += 1
|
||||||
|
@ -21,6 +21,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Nombre de personne par expérience")
|
axes.set_title("Nombre de personne par expérience")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -1,21 +1,10 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
missions = {
|
missions = dict.fromkeys(ressource.mission.choices, 0)
|
||||||
"mission-language": 0,
|
|
||||||
"mission-price": 0,
|
|
||||||
"mission-community-hub": 0,
|
|
||||||
"mission-game-page": 0,
|
|
||||||
"mission-game-dlc": 0,
|
|
||||||
"mission-actuality-new": 0,
|
|
||||||
"mission-profile": 0,
|
|
||||||
"mission-game-discussion": 0,
|
|
||||||
"mission-gift-card": 0,
|
|
||||||
"mission-workshop": 0
|
|
||||||
}
|
|
||||||
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
missions[extract.hardest_mission.extract(data)] += 1
|
missions[extract.hardest_mission.extract(data)] += 1
|
||||||
|
@ -29,8 +18,8 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Mission la plus difficile des personnes sondées")
|
axes.set_title("Mission la plus difficile des personnes sondées")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
axes.set_xticks(x)
|
axes.set_xticks(x)
|
||||||
axes.set_xticklabels(x, rotation=45)
|
axes.set_xticklabels(x, rotation=45)
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
23
tools/statistics/analyse/language.py
Normal file
23
tools/statistics/analyse/language.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
from tools.statistics import extract
|
||||||
|
|
||||||
|
|
||||||
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
|
languages = list(map(extract.language.extract, datas))
|
||||||
|
|
||||||
|
counter = Counter(languages)
|
||||||
|
x = list(counter.keys())
|
||||||
|
y = list(counter.values())
|
||||||
|
|
||||||
|
# prepare plotting
|
||||||
|
figure: plt.Figure = plt.figure()
|
||||||
|
axes = figure.add_subplot(1, 1, 1)
|
||||||
|
axes.set_title("Langue des personnes sondées")
|
||||||
|
|
||||||
|
# bar chart
|
||||||
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
|
return figure
|
|
@ -1,12 +1,12 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
from tools.statistics import extract
|
from tools.statistics import extract, ressource
|
||||||
|
|
||||||
|
|
||||||
def analyse(datas: list[dict]):
|
def analyse(datas: list[dict]) -> plt.Figure:
|
||||||
usage_data = list(map(extract.usage.extract, datas))
|
usage_data = list(map(extract.usage.extract, datas))
|
||||||
|
|
||||||
usages: dict[str, int] = {"always": 0, "often": 0, "sometime": 0, "rarely": 0, "never": 0}
|
usages: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
|
||||||
for usage in usage_data:
|
for usage in usage_data:
|
||||||
usages[usage] += 1
|
usages[usage] += 1
|
||||||
|
|
||||||
|
@ -19,6 +19,6 @@ def analyse(datas: list[dict]):
|
||||||
axes.set_title("Expérience antérieure des personnes sondées")
|
axes.set_title("Expérience antérieure des personnes sondées")
|
||||||
|
|
||||||
# bar chart
|
# bar chart
|
||||||
axes.bar(x, y)
|
axes.bar(x, y, edgecolor='black')
|
||||||
|
|
||||||
plt.show(block=True)
|
return figure
|
||||||
|
|
|
@ -4,3 +4,4 @@ from . import mission_duration
|
||||||
from . import mission_completed
|
from . import mission_completed
|
||||||
from . import experience
|
from . import experience
|
||||||
from . import hardest_mission
|
from . import hardest_mission
|
||||||
|
from . import language
|
||||||
|
|
2
tools/statistics/extract/language.py
Normal file
2
tools/statistics/extract/language.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
def extract(data: dict) -> str:
|
||||||
|
return data["language"]
|
|
@ -2,30 +2,63 @@ from pathlib import Path
|
||||||
|
|
||||||
from tools.statistics.analyse import (age, usage, completion_per_mission, duration_per_mission, completion_per_age,
|
from tools.statistics.analyse import (age, usage, completion_per_mission, duration_per_mission, completion_per_age,
|
||||||
completion_per_usage, duration_per_age, duration_per_usage,
|
completion_per_usage, duration_per_age, duration_per_usage,
|
||||||
completion_per_experience, duration_per_experience, experience, hardest_mission)
|
completion_per_experience, duration_per_experience, experience, hardest_mission,
|
||||||
|
language, duration_per_language, completion_per_language)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from source.utils import compress
|
from source.utils import compress
|
||||||
|
|
||||||
directory = Path(r"./sondage/")
|
# import matplotlib
|
||||||
|
# matplotlib.use("pgf")
|
||||||
|
# matplotlib.rcParams.update({
|
||||||
|
# "pgf.texsystem": "pdflatex",
|
||||||
|
# 'font.family': 'serif',
|
||||||
|
# 'font.size': 11,
|
||||||
|
# 'text.usetex': True,
|
||||||
|
# 'pgf.rcfonts': False,
|
||||||
|
# })
|
||||||
|
|
||||||
# read every people survey data
|
sondage_path = Path(r"./sondage/")
|
||||||
datas = [
|
graph_path = Path(r"./graph/")
|
||||||
|
graph_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# read every peoples survey data
|
||||||
|
datas_all = [
|
||||||
compress.uncompress_data(file.read_bytes()) # decompress the data
|
compress.uncompress_data(file.read_bytes()) # decompress the data
|
||||||
for file in directory.rglob("*.rsl")
|
for file in sondage_path.rglob("*.rsl")
|
||||||
]
|
]
|
||||||
|
|
||||||
age.analyse(datas)
|
# keep only the datas before the steam new year update
|
||||||
usage.analyse(datas)
|
datas_steam_version_1 = list(filter(lambda data: data["time"] < 1704409200, datas_all))
|
||||||
experience.analyse(datas)
|
|
||||||
hardest_mission.analyse(datas)
|
|
||||||
|
|
||||||
completion_per_mission.analyse(datas)
|
# keep only the datas after the steam new year update
|
||||||
completion_per_age.analyse(datas)
|
datas_steam_version_2 = list(filter(lambda data: data["time"] >= 1704409200, datas_all))
|
||||||
completion_per_usage.analyse(datas)
|
|
||||||
completion_per_experience.analyse(datas)
|
|
||||||
|
|
||||||
duration_per_mission.analyse(datas)
|
# regroup all the datas
|
||||||
duration_per_age.analyse(datas)
|
datasets = {
|
||||||
duration_per_usage.analyse(datas)
|
"all": datas_all,
|
||||||
duration_per_experience.analyse(datas)
|
"version_1": datas_steam_version_1,
|
||||||
|
"version_2": datas_steam_version_2,
|
||||||
|
}
|
||||||
|
|
||||||
|
for datas_name, datas in datasets.items():
|
||||||
|
directory = graph_path / datas_name
|
||||||
|
directory.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
age.analyse(datas).savefig(directory / "age.svg")
|
||||||
|
usage.analyse(datas).savefig(directory / "usage.svg")
|
||||||
|
experience.analyse(datas).savefig(directory / "experience.svg")
|
||||||
|
hardest_mission.analyse(datas).savefig(directory / "hardest_mission.svg")
|
||||||
|
language.analyse(datas).savefig(directory / "language.svg")
|
||||||
|
|
||||||
|
completion_per_mission.analyse(datas).savefig(directory / "completion_per_mission.svg")
|
||||||
|
completion_per_age.analyse(datas).savefig(directory / "completion_per_age.svg")
|
||||||
|
completion_per_usage.analyse(datas).savefig(directory / "completion_per_usage.svg")
|
||||||
|
completion_per_experience.analyse(datas).savefig(directory / "completion_per_experience.svg")
|
||||||
|
completion_per_language.analyse(datas).savefig(directory / "completion_per_language.svg")
|
||||||
|
|
||||||
|
duration_per_mission.analyse(datas).savefig(directory / "duration_per_mission.svg")
|
||||||
|
duration_per_age.analyse(datas).savefig(directory / "duration_per_age.svg")
|
||||||
|
duration_per_usage.analyse(datas).savefig(directory / "duration_per_usage.svg")
|
||||||
|
duration_per_experience.analyse(datas).savefig(directory / "duration_per_experience.svg")
|
||||||
|
duration_per_language.analyse(datas).savefig(directory / "duration_per_language.svg")
|
||||||
|
|
3
tools/statistics/ressource/__init__.py
Normal file
3
tools/statistics/ressource/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from . import experience
|
||||||
|
from . import mission
|
||||||
|
from . import usage
|
1
tools/statistics/ressource/experience.py
Normal file
1
tools/statistics/ressource/experience.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
choices = ["yes", "mixed", "no"]
|
12
tools/statistics/ressource/mission.py
Normal file
12
tools/statistics/ressource/mission.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
choices = [
|
||||||
|
"mission-language",
|
||||||
|
"mission-price",
|
||||||
|
"mission-community-hub",
|
||||||
|
"mission-game-page",
|
||||||
|
"mission-game-dlc",
|
||||||
|
"mission-actuality-new",
|
||||||
|
"mission-profile",
|
||||||
|
"mission-game-discussion",
|
||||||
|
"mission-gift-card",
|
||||||
|
"mission-workshop",
|
||||||
|
]
|
1
tools/statistics/ressource/usage.py
Normal file
1
tools/statistics/ressource/usage.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
choices = ["always", "often", "sometime", "rarely", "never"]
|
|
@ -1,6 +0,0 @@
|
||||||
class IntegerQuestion:
|
|
||||||
def get_average(self, datas: list[int]):
|
|
||||||
return sum(datas) / len(datas)
|
|
||||||
|
|
||||||
def get_median(self, datas: list[int]):
|
|
||||||
return datas[len(datas) // 2]
|
|
Loading…
Reference in a new issue