diff --git a/notes_tools/tools/evaluation.py b/notes_tools/tools/evaluation.py index db5eb84..e6a3a35 100644 --- a/notes_tools/tools/evaluation.py +++ b/notes_tools/tools/evaluation.py @@ -6,6 +6,7 @@ import numpy as np from notes_tools.tools.marks_plottings import (pie_pivot_table, parallel_on, radar_on, + hist_boxplot ) import seaborn as sns @@ -187,6 +188,16 @@ class Classe(object): self.exo_df = exo_df self.eval_df = eval_df + @property + def desription(self): + """ Desribe on marks """ + # TODO: not working... |ven. mars 31 18:48:17 EAT 2017 + try: + self._description + except AttributeError: + self._description = self.eval_df["Mark"].describe() + return self._description + @property def marks_tabular(self): """ Latex tabular with marks of students""" @@ -197,6 +208,15 @@ class Classe(object): self._marks_tabular.columns = ["Élèves", "Note"] return self._marks_tabular.to_latex() + @property + def hist_boxplot(self): + """ Marks histogram and associed box plot """ + try: + self._hist_boxplot + except AttributeError: + self._hist_boxplot = hist_boxplot(self.eval_df) + return self._hist_boxplot + @property def level_heatmap(self): """ Heapmap on acheivement level """ diff --git a/notes_tools/tools/marks_plottings.py b/notes_tools/tools/marks_plottings.py index d5ce844..4c35e40 100644 --- a/notes_tools/tools/marks_plottings.py +++ b/notes_tools/tools/marks_plottings.py @@ -67,6 +67,27 @@ def marks_hist(df, **kwargs): return ax +def hist_boxplot(df, kwargs_hist=[], kwargs_box=[]): + f, (ax_hist, ax_box) = plt.subplots(2, sharex=True, + gridspec_kw={"height_ratios": (.85, .15)}) + + marks_hist(df, ax = ax_hist, rwidth=0.9) + + ev_desc = df["Mark"].describe() + m = ev_desc["mean"] + + ax_hist.plot([m,m], ax_hist.get_ylim()) + ax_hist.annotate(round(ev_desc["mean"],1), + xy=(ev_desc["mean"] + 0.2, ax_hist.get_ylim()[1]-0.2)) + + df["Mark"].plot.box(ax = ax_box, vert=False, widths = 0.6) + ax_box.set_yticklabels("") + for e in ["min", "25%", "50%", "75%", "max"]: + ax_box.annotate(ev_desc[e], + xy=(ev_desc[e] - 0.2, ax_box.get_ylim()[1])) + + return f, (ax_hist, ax_box) + def parallel_on(df, index, student=None): """ Plot parallel one line by student