def test_chisquare(self): """ Check if it can calculate chi square when there are no attributes which suppose to be. """ a = DiscreteVariable("a", values=("y", "n")) b = DiscreteVariable("b", values=("y", "n", "o")) table = Table.from_list(Domain([a, b]), list(zip("yynny", "ynyyn"))) chi = ChiSqStats(table, 0, 1) self.assertFalse(isnan(chi.chisq))
def _attribute_changed(self): self.tableview.set_selection(self.selection) self.table = None if self.data and self.rows and self.columns: self.tableview.set_variables(self.rows, self.columns) self.table = contingency_table(self.data, self.columns, self.rows) self.tableview.update_table(self.table.X, formatstr="{:.0f}") chi = ChiSqStats(self.data, self.rows, self.columns) vardata1 = self.data.get_column_view(self.rows.name)[0] vardata2 = self.data.get_column_view(self.columns.name)[0] self.scores.setText( "ARI: {:.3f}\nAMI: {:.3f}\nχ²={:.2f}, p={:.3f}".format( adjusted_rand_score(vardata1, vardata2), adjusted_mutual_info_score(vardata1, vardata2), chi.chisq, chi.p)) else: self.scores.setText("\n\n") self._invalidate()