Skip to content

Commit

Permalink
correction summarize method
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianherreramonterrosa committed Sep 14, 2024
1 parent 7beb0e3 commit 51ff325
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 71 deletions.
2 changes: 1 addition & 1 deletion examples/fit_continuous_iris.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down
80 changes: 40 additions & 40 deletions examples/fit_continuous_ncdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
" <th>0</th>\n",
" <td>weibull</td>\n",
" <td>0.000186</td>\n",
" <td>'alpha': 2.209, 'beta': 10.01</td>\n",
" <td>alpha: 2.209, beta: 10.01</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -344,7 +344,7 @@
" <th>1</th>\n",
" <td>burr</td>\n",
" <td>0.000190</td>\n",
" <td>'A': 114.1, 'B': 2.211, 'C': 219.4</td>\n",
" <td>A: 114.1, B: 2.211, C: 219.4</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -353,7 +353,7 @@
" <th>2</th>\n",
" <td>generalized_gamma</td>\n",
" <td>0.000191</td>\n",
" <td>'a': 11.06, 'd': 2.051, 'p': 2.485</td>\n",
" <td>a: 11.06, d: 2.051, p: 2.485</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -362,7 +362,7 @@
" <th>3</th>\n",
" <td>beta</td>\n",
" <td>0.000194</td>\n",
" <td>'alpha': 2.464, 'beta': 4.881, 'A': 0.1682, 'B...</td>\n",
" <td>alpha: 2.464, beta: 4.881, A: 0.1682, B: 26.09</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -371,7 +371,7 @@
" <th>4</th>\n",
" <td>burr_4p</td>\n",
" <td>0.000195</td>\n",
" <td>'A': 114.1, 'B': 2.211, 'C': 219.4, 'loc': 0.0...</td>\n",
" <td>A: 114.1, B: 2.211, C: 219.4, loc: 0.03258</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -380,7 +380,7 @@
" <th>5</th>\n",
" <td>rice</td>\n",
" <td>0.000212</td>\n",
" <td>'v': 6.614, 'sigma': 5.135</td>\n",
" <td>v: 6.614, sigma: 5.135</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -389,7 +389,7 @@
" <th>6</th>\n",
" <td>weibull_3p</td>\n",
" <td>0.000224</td>\n",
" <td>'alpha': 2.347, 'loc': -0.4928, 'beta': 10.56</td>\n",
" <td>alpha: 2.347, loc: -0.4928, beta: 10.56</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -398,7 +398,7 @@
" <th>7</th>\n",
" <td>johnson_sb</td>\n",
" <td>0.000252</td>\n",
" <td>'xi': -0.7045, 'lambda': 25.63, 'gamma': 0.741...</td>\n",
" <td>xi: -0.7045, lambda: 25.63, gamma: 0.7415, del...</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✅</td>\n",
Expand All @@ -407,7 +407,7 @@
" <th>8</th>\n",
" <td>rayleigh</td>\n",
" <td>0.000388</td>\n",
" <td>'gamma': 0.758, 'sigma': 6.466</td>\n",
" <td>gamma: 0.758, sigma: 6.466</td>\n",
" <td>✖️</td>\n",
" <td>✅</td>\n",
" <td>✖️</td>\n",
Expand All @@ -416,7 +416,7 @@
" <th>9</th>\n",
" <td>pert</td>\n",
" <td>0.000266</td>\n",
" <td>'a': 0.199, 'b': 7.321, 'c': 23.57</td>\n",
" <td>a: 0.199, b: 7.321, c: 23.57</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -425,7 +425,7 @@
" <th>10</th>\n",
" <td>maxwell</td>\n",
" <td>0.000273</td>\n",
" <td>'alpha': 6.29, 'loc': -1.176</td>\n",
" <td>alpha: 6.29, loc: -1.176</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -434,7 +434,7 @@
" <th>11</th>\n",
" <td>nakagami</td>\n",
" <td>0.000461</td>\n",
" <td>'m': 1.269, 'omega': 96.48</td>\n",
" <td>m: 1.269, omega: 96.48</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -443,7 +443,7 @@
" <th>12</th>\n",
" <td>dagum</td>\n",
" <td>0.000516</td>\n",
" <td>'a': 6.113, 'b': 12.5, 'p': 0.2841</td>\n",
" <td>a: 6.113, b: 12.5, p: 0.2841</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -452,7 +452,7 @@
" <th>13</th>\n",
" <td>chi_square_3p</td>\n",
" <td>0.000530</td>\n",
" <td>'df': 30.15, 'loc': -7.586, 'scale': 0.5455</td>\n",
" <td>df: 30.15, loc: -7.586, scale: 0.5455</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -461,7 +461,7 @@
" <th>14</th>\n",
" <td>gamma_3p</td>\n",
" <td>0.000564</td>\n",
" <td>'alpha': 21.53, 'loc': -10.8, 'beta': 0.9129</td>\n",
" <td>alpha: 21.53, loc: -10.8, beta: 0.9129</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -470,7 +470,7 @@
" <th>15</th>\n",
" <td>fatigue_life</td>\n",
" <td>0.000591</td>\n",
" <td>'gamma': 0.2324, 'loc': -9.515, 'scale': 17.89</td>\n",
" <td>gamma: 0.2324, loc: -9.515, scale: 17.89</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -479,7 +479,7 @@
" <th>16</th>\n",
" <td>generalized_extreme_value</td>\n",
" <td>0.000593</td>\n",
" <td>'xi': -0.1341, 'mu': 7.1, 'sigma': 3.783</td>\n",
" <td>xi: -0.1341, mu: 7.1, sigma: 3.783</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -488,7 +488,7 @@
" <th>17</th>\n",
" <td>inverse_gaussian_3p</td>\n",
" <td>0.000598</td>\n",
" <td>'mu': 29.49, 'lambda': 1429, 'loc': -20.63</td>\n",
" <td>mu: 29.49, lambda: 1429, loc: -20.63</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -497,7 +497,7 @@
" <th>18</th>\n",
" <td>dagum_4p</td>\n",
" <td>0.000634</td>\n",
" <td>'a': 6.113, 'b': 12.5, 'p': 0.2841, 'loc': 0.178</td>\n",
" <td>a: 6.113, b: 12.5, p: 0.2841, loc: 0.178</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand All @@ -506,7 +506,7 @@
" <th>19</th>\n",
" <td>inverse_gamma_3p</td>\n",
" <td>0.000645</td>\n",
" <td>'alpha': 39.56, 'loc': -17.41, 'beta': 1013</td>\n",
" <td>alpha: 39.56, loc: -17.41, beta: 1013</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
Expand Down Expand Up @@ -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",
Expand Down
48 changes: 20 additions & 28 deletions examples/fit_discrete_galton_board.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -161,48 +161,48 @@
" <tr>\n",
" <th>0</th>\n",
" <td>binomial</td>\n",
" <td>0.000134</td>\n",
" <td>'n': 12, 'p': 0.5055</td>\n",
" <td>0.000022</td>\n",
" <td>n: 12, p: 0.5028</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>hypergeometric</td>\n",
" <td>0.002552</td>\n",
" <td>'N': 88, 'K': 36, 'n': 14</td>\n",
" <td>0.000043</td>\n",
" <td>N: 89, K: 36, n: 15</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>poisson</td>\n",
" <td>0.012815</td>\n",
" <td>'lambda': 6.004</td>\n",
" <td>0.012716</td>\n",
" <td>lambda: 6.005</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>uniform</td>\n",
" <td>0.085067</td>\n",
" <td>'a': 0, 'b': 12</td>\n",
" <td>0.084674</td>\n",
" <td>a: 0, b: 12</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>geometric</td>\n",
" <td>0.151013</td>\n",
" <td>'p': 0.1666</td>\n",
" <td>0.150568</td>\n",
" <td>p: 0.1665</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>logarithmic</td>\n",
" <td>0.217430</td>\n",
" <td>'p': 0.946</td>\n",
" <td>0.216939</td>\n",
" <td>p: 0.946</td>\n",
" <td>✖️</td>\n",
" <td>✖️</td>\n",
" </tr>\n",
Expand All @@ -211,21 +211,13 @@
"</div>"
],
"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,
Expand Down
4 changes: 2 additions & 2 deletions phitter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "✖️",
Expand All @@ -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 "✖️",
}
Expand Down

0 comments on commit 51ff325

Please sign in to comment.