From 51ff32517e891396e509f39552fce4fa01633f4c Mon Sep 17 00:00:00 2001 From: sebastianherreramonterrosa Date: Sat, 14 Sep 2024 17:27:40 -0500 Subject: [PATCH] correction summarize method --- examples/fit_continuous_iris.ipynb | 2 +- examples/fit_continuous_ncdb.ipynb | 80 ++++++++++++------------ examples/fit_discrete_galton_board.ipynb | 48 ++++++-------- phitter/main.py | 4 +- 4 files changed, 63 insertions(+), 71 deletions(-) diff --git a/examples/fit_continuous_iris.ipynb b/examples/fit_continuous_iris.ipynb index 8cf6d24..e680f10 100644 --- a/examples/fit_continuous_iris.ipynb +++ b/examples/fit_continuous_iris.ipynb @@ -159,7 +159,7 @@ "outputs": [], "source": [ "phitter_cont = phitter.PHITTER(data=data)\n", - "phitter_cont.fit(n_workers=6)" + "phitter_cont.fit(n_workers=2)" ] }, { diff --git a/examples/fit_continuous_ncdb.ipynb b/examples/fit_continuous_ncdb.ipynb index f4ca283..75a2dc4 100644 --- a/examples/fit_continuous_ncdb.ipynb +++ b/examples/fit_continuous_ncdb.ipynb @@ -335,7 +335,7 @@ " 0\n", " weibull\n", " 0.000186\n", - " 'alpha': 2.209, 'beta': 10.01\n", + " alpha: 2.209, beta: 10.01\n", " ✖️\n", " ✅\n", " ✅\n", @@ -344,7 +344,7 @@ " 1\n", " burr\n", " 0.000190\n", - " 'A': 114.1, 'B': 2.211, 'C': 219.4\n", + " A: 114.1, B: 2.211, C: 219.4\n", " ✖️\n", " ✅\n", " ✅\n", @@ -353,7 +353,7 @@ " 2\n", " generalized_gamma\n", " 0.000191\n", - " 'a': 11.06, 'd': 2.051, 'p': 2.485\n", + " a: 11.06, d: 2.051, p: 2.485\n", " ✖️\n", " ✅\n", " ✅\n", @@ -362,7 +362,7 @@ " 3\n", " beta\n", " 0.000194\n", - " 'alpha': 2.464, 'beta': 4.881, 'A': 0.1682, 'B...\n", + " alpha: 2.464, beta: 4.881, A: 0.1682, B: 26.09\n", " ✖️\n", " ✅\n", " ✅\n", @@ -371,7 +371,7 @@ " 4\n", " burr_4p\n", " 0.000195\n", - " 'A': 114.1, 'B': 2.211, 'C': 219.4, 'loc': 0.0...\n", + " A: 114.1, B: 2.211, C: 219.4, loc: 0.03258\n", " ✖️\n", " ✅\n", " ✅\n", @@ -380,7 +380,7 @@ " 5\n", " rice\n", " 0.000212\n", - " 'v': 6.614, 'sigma': 5.135\n", + " v: 6.614, sigma: 5.135\n", " ✖️\n", " ✅\n", " ✅\n", @@ -389,7 +389,7 @@ " 6\n", " weibull_3p\n", " 0.000224\n", - " 'alpha': 2.347, 'loc': -0.4928, 'beta': 10.56\n", + " alpha: 2.347, loc: -0.4928, beta: 10.56\n", " ✖️\n", " ✅\n", " ✅\n", @@ -398,7 +398,7 @@ " 7\n", " johnson_sb\n", " 0.000252\n", - " 'xi': -0.7045, 'lambda': 25.63, 'gamma': 0.741...\n", + " xi: -0.7045, lambda: 25.63, gamma: 0.7415, del...\n", " ✖️\n", " ✅\n", " ✅\n", @@ -407,7 +407,7 @@ " 8\n", " rayleigh\n", " 0.000388\n", - " 'gamma': 0.758, 'sigma': 6.466\n", + " gamma: 0.758, sigma: 6.466\n", " ✖️\n", " ✅\n", " ✖️\n", @@ -416,7 +416,7 @@ " 9\n", " pert\n", " 0.000266\n", - " 'a': 0.199, 'b': 7.321, 'c': 23.57\n", + " a: 0.199, b: 7.321, c: 23.57\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -425,7 +425,7 @@ " 10\n", " maxwell\n", " 0.000273\n", - " 'alpha': 6.29, 'loc': -1.176\n", + " alpha: 6.29, loc: -1.176\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -434,7 +434,7 @@ " 11\n", " nakagami\n", " 0.000461\n", - " 'm': 1.269, 'omega': 96.48\n", + " m: 1.269, omega: 96.48\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -443,7 +443,7 @@ " 12\n", " dagum\n", " 0.000516\n", - " 'a': 6.113, 'b': 12.5, 'p': 0.2841\n", + " a: 6.113, b: 12.5, p: 0.2841\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -452,7 +452,7 @@ " 13\n", " chi_square_3p\n", " 0.000530\n", - " 'df': 30.15, 'loc': -7.586, 'scale': 0.5455\n", + " df: 30.15, loc: -7.586, scale: 0.5455\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -461,7 +461,7 @@ " 14\n", " gamma_3p\n", " 0.000564\n", - " 'alpha': 21.53, 'loc': -10.8, 'beta': 0.9129\n", + " alpha: 21.53, loc: -10.8, beta: 0.9129\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -470,7 +470,7 @@ " 15\n", " fatigue_life\n", " 0.000591\n", - " 'gamma': 0.2324, 'loc': -9.515, 'scale': 17.89\n", + " gamma: 0.2324, loc: -9.515, scale: 17.89\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -479,7 +479,7 @@ " 16\n", " generalized_extreme_value\n", " 0.000593\n", - " 'xi': -0.1341, 'mu': 7.1, 'sigma': 3.783\n", + " xi: -0.1341, mu: 7.1, sigma: 3.783\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -488,7 +488,7 @@ " 17\n", " inverse_gaussian_3p\n", " 0.000598\n", - " 'mu': 29.49, 'lambda': 1429, 'loc': -20.63\n", + " mu: 29.49, lambda: 1429, loc: -20.63\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -497,7 +497,7 @@ " 18\n", " dagum_4p\n", " 0.000634\n", - " 'a': 6.113, 'b': 12.5, 'p': 0.2841, 'loc': 0.178\n", + " a: 6.113, b: 12.5, p: 0.2841, loc: 0.178\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -506,7 +506,7 @@ " 19\n", " inverse_gamma_3p\n", " 0.000645\n", - " 'alpha': 39.56, 'loc': -17.41, 'beta': 1013\n", + " alpha: 39.56, loc: -17.41, beta: 1013\n", " ✖️\n", " ✖️\n", " ✖️\n", @@ -539,26 +539,26 @@ "19 inverse_gamma_3p 0.000645 \n", "\n", " parameters chi_square \\\n", - "0 'alpha': 2.209, 'beta': 10.01 ✖️ \n", - "1 'A': 114.1, 'B': 2.211, 'C': 219.4 ✖️ \n", - "2 'a': 11.06, 'd': 2.051, 'p': 2.485 ✖️ \n", - "3 'alpha': 2.464, 'beta': 4.881, 'A': 0.1682, 'B... ✖️ \n", - "4 'A': 114.1, 'B': 2.211, 'C': 219.4, 'loc': 0.0... ✖️ \n", - "5 'v': 6.614, 'sigma': 5.135 ✖️ \n", - "6 'alpha': 2.347, 'loc': -0.4928, 'beta': 10.56 ✖️ \n", - "7 'xi': -0.7045, 'lambda': 25.63, 'gamma': 0.741... ✖️ \n", - "8 'gamma': 0.758, 'sigma': 6.466 ✖️ \n", - "9 'a': 0.199, 'b': 7.321, 'c': 23.57 ✖️ \n", - "10 'alpha': 6.29, 'loc': -1.176 ✖️ \n", - "11 'm': 1.269, 'omega': 96.48 ✖️ \n", - "12 'a': 6.113, 'b': 12.5, 'p': 0.2841 ✖️ \n", - "13 'df': 30.15, 'loc': -7.586, 'scale': 0.5455 ✖️ \n", - "14 'alpha': 21.53, 'loc': -10.8, 'beta': 0.9129 ✖️ \n", - "15 'gamma': 0.2324, 'loc': -9.515, 'scale': 17.89 ✖️ \n", - "16 'xi': -0.1341, 'mu': 7.1, 'sigma': 3.783 ✖️ \n", - "17 'mu': 29.49, 'lambda': 1429, 'loc': -20.63 ✖️ \n", - "18 'a': 6.113, 'b': 12.5, 'p': 0.2841, 'loc': 0.178 ✖️ \n", - "19 'alpha': 39.56, 'loc': -17.41, 'beta': 1013 ✖️ \n", + "0 alpha: 2.209, beta: 10.01 ✖️ \n", + "1 A: 114.1, B: 2.211, C: 219.4 ✖️ \n", + "2 a: 11.06, d: 2.051, p: 2.485 ✖️ \n", + "3 alpha: 2.464, beta: 4.881, A: 0.1682, B: 26.09 ✖️ \n", + "4 A: 114.1, B: 2.211, C: 219.4, loc: 0.03258 ✖️ \n", + "5 v: 6.614, sigma: 5.135 ✖️ \n", + "6 alpha: 2.347, loc: -0.4928, beta: 10.56 ✖️ \n", + "7 xi: -0.7045, lambda: 25.63, gamma: 0.7415, del... ✖️ \n", + "8 gamma: 0.758, sigma: 6.466 ✖️ \n", + "9 a: 0.199, b: 7.321, c: 23.57 ✖️ \n", + "10 alpha: 6.29, loc: -1.176 ✖️ \n", + "11 m: 1.269, omega: 96.48 ✖️ \n", + "12 a: 6.113, b: 12.5, p: 0.2841 ✖️ \n", + "13 df: 30.15, loc: -7.586, scale: 0.5455 ✖️ \n", + "14 alpha: 21.53, loc: -10.8, beta: 0.9129 ✖️ \n", + "15 gamma: 0.2324, loc: -9.515, scale: 17.89 ✖️ \n", + "16 xi: -0.1341, mu: 7.1, sigma: 3.783 ✖️ \n", + "17 mu: 29.49, lambda: 1429, loc: -20.63 ✖️ \n", + "18 a: 6.113, b: 12.5, p: 0.2841, loc: 0.178 ✖️ \n", + "19 alpha: 39.56, loc: -17.41, beta: 1013 ✖️ \n", "\n", " kolmogorov_smirnov anderson_darling \n", "0 ✅ ✅ \n", diff --git a/examples/fit_discrete_galton_board.ipynb b/examples/fit_discrete_galton_board.ipynb index b924550..baee5b2 100644 --- a/examples/fit_discrete_galton_board.ipynb +++ b/examples/fit_discrete_galton_board.ipynb @@ -105,7 +105,7 @@ { "data": { "text/plain": [ - "{'id': 'binomial', 'parameters': {'n': 12, 'p': 0.5055089627278152}}" + "{'id': 'binomial', 'parameters': {'n': 12, 'p': 0.5028013586032182}}" ] }, "execution_count": 6, @@ -161,48 +161,48 @@ " \n", " 0\n", " binomial\n", - " 0.000134\n", - " 'n': 12, 'p': 0.5055\n", + " 0.000022\n", + " n: 12, p: 0.5028\n", " ✖️\n", " ✖️\n", " \n", " \n", " 1\n", " hypergeometric\n", - " 0.002552\n", - " 'N': 88, 'K': 36, 'n': 14\n", + " 0.000043\n", + " N: 89, K: 36, n: 15\n", " ✖️\n", " ✖️\n", " \n", " \n", " 2\n", " poisson\n", - " 0.012815\n", - " 'lambda': 6.004\n", + " 0.012716\n", + " lambda: 6.005\n", " ✖️\n", " ✖️\n", " \n", " \n", " 3\n", " uniform\n", - " 0.085067\n", - " 'a': 0, 'b': 12\n", + " 0.084674\n", + " a: 0, b: 12\n", " ✖️\n", " ✖️\n", " \n", " \n", " 4\n", " geometric\n", - " 0.151013\n", - " 'p': 0.1666\n", + " 0.150568\n", + " p: 0.1665\n", " ✖️\n", " ✖️\n", " \n", " \n", " 5\n", " logarithmic\n", - " 0.217430\n", - " 'p': 0.946\n", + " 0.216939\n", + " p: 0.946\n", " ✖️\n", " ✖️\n", " \n", @@ -211,21 +211,13 @@ "" ], "text/plain": [ - " distribution sse parameters chi_square \\\n", - "0 binomial 0.000134 'n': 12, 'p': 0.5055 ✖️ \n", - "1 hypergeometric 0.002552 'N': 88, 'K': 36, 'n': 14 ✖️ \n", - "2 poisson 0.012815 'lambda': 6.004 ✖️ \n", - "3 uniform 0.085067 'a': 0, 'b': 12 ✖️ \n", - "4 geometric 0.151013 'p': 0.1666 ✖️ \n", - "5 logarithmic 0.217430 'p': 0.946 ✖️ \n", - "\n", - " kolmogorov_smirnov \n", - "0 ✖️ \n", - "1 ✖️ \n", - "2 ✖️ \n", - "3 ✖️ \n", - "4 ✖️ \n", - "5 ✖️ " + " distribution sse parameters chi_square kolmogorov_smirnov\n", + "0 binomial 0.000022 n: 12, p: 0.5028 ✖️ ✖️\n", + "1 hypergeometric 0.000043 N: 89, K: 36, n: 15 ✖️ ✖️\n", + "2 poisson 0.012716 lambda: 6.005 ✖️ ✖️\n", + "3 uniform 0.084674 a: 0, b: 12 ✖️ ✖️\n", + "4 geometric 0.150568 p: 0.1665 ✖️ ✖️\n", + "5 logarithmic 0.216939 p: 0.946 ✖️ ✖️" ] }, "execution_count": 7, diff --git a/phitter/main.py b/phitter/main.py index b998086..5b93642 100644 --- a/phitter/main.py +++ b/phitter/main.py @@ -197,7 +197,7 @@ def summarize(self, k: int = 20): { "distribution": id_distribution, "sse": info["sse"], - "parameters": ", ".join([f"'{k}': {v:.4g}" for k, v in info["parameters"].items()]), + "parameters": ", ".join([f"{k}: {v:.4g}" for k, v in info["parameters"].items()]), "chi_square": "✅" if info["chi_square"]["rejected"] == False else "✖️", "kolmogorov_smirnov": "✅" if info["kolmogorov_smirnov"]["rejected"] == False else "✖️", "anderson_darling": "✅" if info["anderson_darling"]["rejected"] == False else "✖️", @@ -212,7 +212,7 @@ def summarize(self, k: int = 20): { "distribution": id_distribution, "sse": info["sse"], - "parameters": ", ".join([f"'{k}': {v:.4g}" for k, v in info["parameters"].items()]), + "parameters": ", ".join([f"{k}: {v:.4g}" for k, v in info["parameters"].items()]), "chi_square": "✅" if info["chi_square"]["rejected"] == False else "✖️", "kolmogorov_smirnov": "✅" if info["kolmogorov_smirnov"]["rejected"] == False else "✖️", }