def __stats(self, data: [[float]], y: [float]) -> []: stats = [{} for i in range(len(data) + 1)] y_stats = Statistics.describe(y) (y_variance, y_std) = Statistics.variance(y, y_stats["mean"]) y_stats["covariance"] = y_variance y_stats["r"] = 1.0 y_stats["pr"] = 1.0 stats[0] = y_stats for i in range(len(data)): s = Statistics.describe(data[i]) (covariance, r) = Statistics.covariance(data[i], y, s["mean"], y_stats["mean"]) s["covariance"] = covariance s["r"] = r s["pr"] = self.__partial_mat__[0][i + 1] stats[i + 1] = s return stats
def test_describe(self): data = [1, 2, 3, 4, 5, 6, 7, 8, 9] stats = Statistics.describe(data) self.assertEqual(stats["count"], 9) self.assertEqual(stats["mean"], 5.0) self.assertEqual(stats["variance"], 7.5) self.assertEqual(stats["std"], 2.7386127875258306) self.assertEqual(stats["min"], 1) self.assertEqual(stats["max"], 9)
def __model_stats(self, y:[float], ycap:[float]) -> {}: error = [0.0 for x in range(len(y))] for i in range(len(y)): error[i] = y[i] - ycap[i] s = Statistics.describe(error) return s