Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
|
| 3 |
-
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
| 4 |
|
| 5 |
from pathlib import Path
|
| 6 |
import io
|
|
@@ -77,7 +77,7 @@ DARK_MODE_HEAD = """<script>
|
|
| 77 |
const url = new URL(window.location.href);
|
| 78 |
if (!url.searchParams.has("__theme")) {
|
| 79 |
url.searchParams.set("__theme", "dark");
|
| 80 |
-
window.
|
| 81 |
}
|
| 82 |
})();
|
| 83 |
</script>"""
|
|
@@ -363,7 +363,6 @@ def build_code(analysis, x, y, group, subject, within, dv, selected_vars, covars
|
|
| 363 |
if model_family == "OLS (ANOVA / ANCOVA)":
|
| 364 |
return f'''import statsmodels.formula.api as smf
|
| 365 |
from statsmodels.stats.anova import anova_lm
|
| 366 |
-
|
| 367 |
d = df[{selected!r}].dropna().copy()
|
| 368 |
model = smf.ols(formula={f"Q({outcome!r}) ~ {rhs}"!r}, data=d).fit()
|
| 369 |
result = model.summary2().tables[1]
|
|
@@ -373,7 +372,6 @@ anova = anova_lm(model, typ=2)'''
|
|
| 373 |
fit = "logit" if model_family.startswith("Logit") else "probit"
|
| 374 |
return f'''import statsmodels.formula.api as smf
|
| 375 |
from scipy.stats import chi2
|
| 376 |
-
|
| 377 |
d = df[{selected!r}].dropna().copy()
|
| 378 |
d["__outcome"] = pd.Categorical(d[{outcome!r}]).codes
|
| 379 |
if d["__outcome"].nunique() != 2:
|
|
@@ -387,7 +385,6 @@ overall = pd.DataFrame({{"LR chi2": [model.llr], "df": [model.df_model], "p-valu
|
|
| 387 |
import patsy
|
| 388 |
from scipy.stats import chi2
|
| 389 |
from statsmodels.miscmodels.ordinal_model import OrderedModel
|
| 390 |
-
|
| 391 |
d = df[{selected!r}].dropna().copy()
|
| 392 |
d["__outcome"] = pd.Categorical(d[{outcome!r}].astype(str), categories={levels!r}, ordered=True).codes
|
| 393 |
if (d["__outcome"] < 0).any() or d["__outcome"].nunique() < 2:
|
|
@@ -412,7 +409,6 @@ overall = pd.DataFrame({{"LR chi2": [lr_chi2], "df": [X.shape[1]], "p-value": [c
|
|
| 412 |
return f'''import statsmodels.api as sm
|
| 413 |
import statsmodels.formula.api as smf
|
| 414 |
from scipy.stats import chi2
|
| 415 |
-
|
| 416 |
d = df[{selected!r}].dropna().copy()
|
| 417 |
{response}family = {family}
|
| 418 |
model = smf.glm(formula={f"{glm_outcome} ~ {rhs}"!r}, data=d, family=family).fit()
|
|
|
|
| 1 |
+
#import asyncio
|
| 2 |
|
| 3 |
+
#asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
| 4 |
|
| 5 |
from pathlib import Path
|
| 6 |
import io
|
|
|
|
| 77 |
const url = new URL(window.location.href);
|
| 78 |
if (!url.searchParams.has("__theme")) {
|
| 79 |
url.searchParams.set("__theme", "dark");
|
| 80 |
+
window.location.replace(url);
|
| 81 |
}
|
| 82 |
})();
|
| 83 |
</script>"""
|
|
|
|
| 363 |
if model_family == "OLS (ANOVA / ANCOVA)":
|
| 364 |
return f'''import statsmodels.formula.api as smf
|
| 365 |
from statsmodels.stats.anova import anova_lm
|
|
|
|
| 366 |
d = df[{selected!r}].dropna().copy()
|
| 367 |
model = smf.ols(formula={f"Q({outcome!r}) ~ {rhs}"!r}, data=d).fit()
|
| 368 |
result = model.summary2().tables[1]
|
|
|
|
| 372 |
fit = "logit" if model_family.startswith("Logit") else "probit"
|
| 373 |
return f'''import statsmodels.formula.api as smf
|
| 374 |
from scipy.stats import chi2
|
|
|
|
| 375 |
d = df[{selected!r}].dropna().copy()
|
| 376 |
d["__outcome"] = pd.Categorical(d[{outcome!r}]).codes
|
| 377 |
if d["__outcome"].nunique() != 2:
|
|
|
|
| 385 |
import patsy
|
| 386 |
from scipy.stats import chi2
|
| 387 |
from statsmodels.miscmodels.ordinal_model import OrderedModel
|
|
|
|
| 388 |
d = df[{selected!r}].dropna().copy()
|
| 389 |
d["__outcome"] = pd.Categorical(d[{outcome!r}].astype(str), categories={levels!r}, ordered=True).codes
|
| 390 |
if (d["__outcome"] < 0).any() or d["__outcome"].nunique() < 2:
|
|
|
|
| 409 |
return f'''import statsmodels.api as sm
|
| 410 |
import statsmodels.formula.api as smf
|
| 411 |
from scipy.stats import chi2
|
|
|
|
| 412 |
d = df[{selected!r}].dropna().copy()
|
| 413 |
{response}family = {family}
|
| 414 |
model = smf.glm(formula={f"{glm_outcome} ~ {rhs}"!r}, data=d, family=family).fit()
|