-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paths01_01.py
55 lines (47 loc) · 1.61 KB
/
s01_01.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Reviewers and ratings: Expertise Level vs Rating"""
from asyncio import run
from matplotlib import pyplot as plt
from matplotlib.axes import Axes
from pandas import DataFrame
from seaborn import barplot
from sqlalchemy import func
from sqlalchemy.future import select
from uvloop import install
from cmt_statistics_tool.statistics import get_data, plot_df
from cmt_statistics_tool.tables import SubmissionReview
async def main() -> DataFrame:
statement = (
select(
SubmissionReview.overall_rating, SubmissionReview.confidence, func.count()
)
.group_by(SubmissionReview.overall_rating, SubmissionReview.confidence)
.order_by(SubmissionReview.overall_rating, SubmissionReview.confidence)
)
df = DataFrame(await get_data(statement)).rename(
columns={0: "Status", 1: "Expertise", 2: "Count"}
)
df2 = df.groupby("Expertise").sum().reset_index()
df2.insert(0, "Status", "All")
return df.append(df2)
def plot(df: DataFrame, ax: Axes) -> None:
ax.set_title("Expertise level and rating (original submissions)")
barplot(
x="Status",
y="Count",
hue="Expertise",
order=["Accept", "Weak Accept", "Weak Reject", "Reject", "All"],
hue_order=[
"Expert in this problem",
"Knowledgeable in this sub-area ",
"Generally aware of the area",
"Had to use common sense and general knowledge",
],
data=df,
ax=ax,
)
if __name__ == "__main__":
install()
df = run(main())
fig = plot_df(df, plot)
plt.savefig("plots/01_01.png")
print(df)