I am working on a project in which my expected outcome is which classifier has performed very well on the basis of F1 Score. I am conducting a t-test for the difference of means to assess which algorithm achieves higher F1 score.
I have F1 Score of both classifiers alog_A: 0.589744 and algo_B: 0.641026
Following is the code that I am using to meet my project requirements but from this code I am getting any of the resuls it's showing me NaN. How I can fix this issue?
from scipy import stats
t_value,p_value=stats.ttest_ind(f1_score_Algo_A,f1_score_Algo_B)
print('Test statistic is %f'%float("{:.6f}".format(t_value)))
print('p-value for two tailed test is %f'%p_value)
I am getting the following output
Test statistic is nan
p-value for two tailed test is nan
My expected results is which algorithm has performed well with t-test difference value and p_value.
Try this, note that in this case both
f1_scores_Algo_Aandf1_scores_Algo_Bare lists and can be treated as two independent samples of scores:The next plot shows the distribution of F1-scores obtained with different train-test splits with the models.
Now, we can do the paired
t-test:so that we can reject the null hypothesis (that 2 independent samples have identical average scores) at 5% level of significance.