def asssistant(): values = request.json data = {'n': len(values.values()[0]), 'k': len(values.keys())} # Paired? values_clean = clean_missing_values(request.json) data['paired'] = True if data['n'] == len( values_clean.values()[0]) else False # Normality? alpha = 0.1 values_clean = clean_missing_values(request.json, delete_row=False) _, p_values = map(list, zip(*[st.shapiro(v) for v in values_clean.values()])) data['normality'] = int( reduce(lambda x, y: x and y, [p_value < alpha for p_value in p_values])) # Homocedasticity? _, p_value = st.levene(*values_clean.values()) data['homocedasticity'] = int(p_value < alpha) data.update(evaluate_test(data)) return data
def mannwhitneyu(alpha=0.05): values = clean_missing_values(request.json, delete_row=False) statistic, p_value = st.mannwhitneyu(values.values()[0], values.values()[1], use_continuity="false") result = int(p_value * 2 < alpha) return {"result": result, "statistic": statistic, "p_value": p_value * 2}
def ttest_ind(alpha=0.05): values = clean_missing_values(request.json) statistic, p_value = st.ttest_ind(values.values()[0], values.values()[1]) result = int(p_value < alpha) return { "statistic": statistic.tolist(), "p_value": p_value, "result": result }
def quade(alpha=0.05, post_hoc="bonferroni_dunn_test", control=None): values = clean_missing_values(request.json) statistic, p_value, rankings, ranking_cmp = npt.quade_test( *values.values()) rankings, names = map( list, zip(*sorted(zip(rankings, values.keys()), key=lambda t: t[0]))) ranks = {key: ranking_cmp[i] for i, key in enumerate(values.keys())} if post_hoc.split('_')[-1] == "test": comparisons, z_values, _, adj_p_values = getattr(npt, post_hoc)(ranks, control) else: comparisons, z_values, _, adj_p_values = getattr(npt, post_hoc)(ranks) return statistic, p_value, rankings, names, comparisons, z_values, adj_p_values
def anova(alpha=0.05): values = clean_missing_values(request.json) statistic, p_value, pivots = pt.anova_within_test(*values.values()) pivots_cmp = {key: pivots[i] for i, key in enumerate(values.keys())} comparisons, t_values, _, adj_p_values = pt.bonferroni_test( pivots_cmp, len(values.values()[0])) return { "anova": { "statistic": statistic, "p_value": p_value, "result": np.asscalar(p_value < alpha) }, "post_hoc": { "comparisons": comparisons, "statistic": t_values, "p_value": adj_p_values, "result": [int(adj_p_value < alpha) for adj_p_value in adj_p_values] } }
def wilcoxon(alpha=0.05): values = clean_missing_values(request.json) statistic, p_value = st.wilcoxon(values.values()[0], values.values()[1]) result = int(p_value < alpha) return {"result": result, "statistic": statistic, "p_value": p_value}
def binomialsign(alpha=0.05): values = clean_missing_values(request.json) statistic, p_value = npt.binomial_sign_test(values.values()[0], values.values()[1]) result = int(p_value < alpha) return {"result": result, "statistic": statistic, "p_value": p_value}
def levene(alpha=0.05): values = clean_missing_values(request.json, delete_row=False) statistic, p_value = st.levene(*values.values()) result = int(p_value < alpha) return {"statistic": statistic, "p_value": p_value, "result": result}
def agostino(alpha=0.05): values = clean_missing_values(request.json, delete_row=False) statistics, p_values = map( list, zip(*[st.normaltest(v) for v in values.values()])) result = [int(p_value < alpha) for p_value in p_values] return {"statistic": statistics, "p_value": p_values, "result": result}