Repository: statsmodels/statsmodels
Pull request: Clean up the smf namespace 
Removes unused classes from the smf namespace, closes #4947 and #833.

Problem statement:
Confusion regarding the smf module
This code works fine as expected:

```python
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf

n = 100
data = pd.DataFrame({"y": np.random.poisson(lam=1, size=n), 
                     "x": np.random.randn(n)})

result = smf.poisson("y ~ x", data).fit()
result.summary()
```

The problem happens when the user mistakenly tries to use the `Poisson` class (which doesn't use the formula syntax, yet it is imported within the module nonetheless and will even autocomplete if the user makes the mistake of capitalizing the P) within the `smf` class as below,

```python
result = smf.Poisson("y ~ x", data).fit()
result.summary()
```

It is very easy to make this mistake and the resulting error message is quite cryptic, so I am wondering if there is a way to fix this.  It seems that the `smf` module should not directly expose those classes that don't follow the formula syntax.

Hints from issue discussion:
this got lost #833
we just need `del xxx` to remove the original classes from the namespace
@josef-pkt I created a pull request for this.  I think it went through, although I'm seeing some git weirdness locally.
No need for del.  Just use `__all__` which is the standard method to limit namespace.
`__all__` still leaves the classes in the name space and is not enough.
`__all__` works for `from xxx import *` and a few other things.
`__all__` is enough that tab completion will not pick them up, which should be the goal.
Oops, you are right -- it doesn't hide from IPython.  So `del` it is.
I'm closing this as duplicate of #833

Commit message: clean up smf namespace

Patch to review:
diff --git a/statsmodels/formula/api.py b/statsmodels/formula/api.py
index b75a0119b27..3d7d951310c 100644
--- a/statsmodels/formula/api.py
+++ b/statsmodels/formula/api.py
@@ -1,33 +1,28 @@
-from statsmodels.regression.linear_model import GLS
-gls = GLS.from_formula
-from statsmodels.regression.linear_model import WLS
-wls = WLS.from_formula
-from statsmodels.regression.linear_model import OLS
-ols = OLS.from_formula
-from statsmodels.regression.linear_model import GLSAR
-glsar = GLSAR.from_formula
-from statsmodels.regression.mixed_linear_model import MixedLM
-mixedlm = MixedLM.from_formula
-from statsmodels.genmod.generalized_linear_model import GLM
-glm = GLM.from_formula
-from statsmodels.robust.robust_linear_model import RLM
-rlm = RLM.from_formula
-from statsmodels.discrete.discrete_model import MNLogit
-mnlogit = MNLogit.from_formula
-from statsmodels.discrete.discrete_model import Logit
-logit = Logit.from_formula
-from statsmodels.discrete.discrete_model import Probit
-probit = Probit.from_formula
-from statsmodels.discrete.discrete_model import Poisson
-poisson = Poisson.from_formula
-from statsmodels.discrete.discrete_model import NegativeBinomial
-negativebinomial = NegativeBinomial.from_formula
-from statsmodels.regression.quantile_regression import QuantReg
-quantreg = QuantReg.from_formula
-from statsmodels.duration.hazard_regression import PHReg
-phreg = PHReg.from_formula
-from statsmodels.genmod.generalized_estimating_equations import (GEE,
-     OrdinalGEE, NominalGEE)
-gee = GEE.from_formula
-ordinal_gee = OrdinalGEE.from_formula
-nominal_gee = NominalGEE.from_formula
+import statsmodels.regression.linear_model as lm
+import statsmodels.discrete.discrete_model as dm
+import statsmodels.regression.mixed_linear_model as mlm
+import statsmodels.genmod.generalized_linear_model as glm
+import statsmodels.robust.robust_linear_model as roblm
+import statsmodels.regression.quantile_regression as qr
+import statsmodels.duration.hazard_regression as hr
+import statsmodels.genmod.generalized_estimating_equations as gee
+
+gls = lm.GLS.from_formula
+wls = lm.WLS.from_formula
+ols = lm.OLS.from_formula
+glsar = lm.GLSAR.from_formula
+mixedlm = mlm.MixedLM.from_formula
+glm = glm.GLM.from_formula
+rlm = roblm.RLM.from_formula
+mnlogit = dm.MNLogit.from_formula
+logit = dm.Logit.from_formula
+probit = dm.Probit.from_formula
+poisson = dm.Poisson.from_formula
+negativebinomial = dm.NegativeBinomial.from_formula
+quantreg = qr.QuantReg.from_formula
+phreg = hr.PHReg.from_formula
+ordinal_gee = gee.OrdinalGEE.from_formula
+nominal_gee = gee.NominalGEE.from_formula
+gee = gee.GEE.from_formula
+
+del lm, dm, mlm, glm, roblm, qr, hr


Code review comments:
diff_hunk: @@ -1,33 +1,28 @@
-from statsmodels.regression.linear_model import GLS
-gls = GLS.from_formula
-from statsmodels.regression.linear_model import WLS
-wls = WLS.from_formula
-from statsmodels.regression.linear_model import OLS
-ols = OLS.from_formula
-from statsmodels.regression.linear_model import GLSAR
-glsar = GLSAR.from_formula
-from statsmodels.regression.mixed_linear_model import MixedLM
-mixedlm = MixedLM.from_formula
-from statsmodels.genmod.generalized_linear_model import GLM
-glm = GLM.from_formula
-from statsmodels.robust.robust_linear_model import RLM
-rlm = RLM.from_formula
-from statsmodels.discrete.discrete_model import MNLogit
-mnlogit = MNLogit.from_formula
-from statsmodels.discrete.discrete_model import Logit
-logit = Logit.from_formula
-from statsmodels.discrete.discrete_model import Probit
-probit = Probit.from_formula
-from statsmodels.discrete.discrete_model import Poisson
-poisson = Poisson.from_formula
-from statsmodels.discrete.discrete_model import NegativeBinomial
-negativebinomial = NegativeBinomial.from_formula
-from statsmodels.regression.quantile_regression import QuantReg
-quantreg = QuantReg.from_formula
-from statsmodels.duration.hazard_regression import PHReg
-phreg = PHReg.from_formula
-from statsmodels.genmod.generalized_estimating_equations import (GEE,
-     OrdinalGEE, NominalGEE)
-gee = GEE.from_formula
-ordinal_gee = OrdinalGEE.from_formula
-nominal_gee = NominalGEE.from_formula
+import statsmodels.regression.linear_model as lm
+import statsmodels.discrete.discrete_model as dm
+import statsmodels.regression.mixed_linear_model as mlm
+import statsmodels.genmod.generalized_linear_model as glm
+import statsmodels.robust.robust_linear_model as roblm
+import statsmodels.regression.quantile_regression as qr
+import statsmodels.duration.hazard_regression as hr
+import statsmodels.genmod.generalized_estimating_equations as gee
+
+gls = lm.GLS.from_formula
+wls = lm.WLS.from_formula
+ols = lm.OLS.from_formula
+glsar = lm.GLSAR.from_formula
+mixedlm = mlm.MixedLM.from_formula
+glm = glm.GLM.from_formula
+rlm = roblm.RLM.from_formula
+mnlogit = dm.MNLogit.from_formula
+logit = dm.Logit.from_formula
+probit = dm.Probit.from_formula
+poisson = dm.Poisson.from_formula
+negativebinomial = dm.NegativeBinomial.from_formula
+quantreg = qr.QuantReg.from_formula
+phreg = hr.PHReg.from_formula
+ordinal_gee = gee.OrdinalGEE.from_formula
+nominal_gee = gee.NominalGEE.from_formula
+gee = gee.GEE.from_formula
+
+del lm, dm, mlm, glm, roblm, qr, hr
path: statsmodels/formula/api.py
text: @user1:
Dont delete glm.

diff_hunk: @@ -1,33 +1,28 @@
-from statsmodels.regression.linear_model import GLS
-gls = GLS.from_formula
-from statsmodels.regression.linear_model import WLS
-wls = WLS.from_formula
-from statsmodels.regression.linear_model import OLS
-ols = OLS.from_formula
-from statsmodels.regression.linear_model import GLSAR
-glsar = GLSAR.from_formula
-from statsmodels.regression.mixed_linear_model import MixedLM
-mixedlm = MixedLM.from_formula
-from statsmodels.genmod.generalized_linear_model import GLM
-glm = GLM.from_formula
-from statsmodels.robust.robust_linear_model import RLM
-rlm = RLM.from_formula
-from statsmodels.discrete.discrete_model import MNLogit
-mnlogit = MNLogit.from_formula
-from statsmodels.discrete.discrete_model import Logit
-logit = Logit.from_formula
-from statsmodels.discrete.discrete_model import Probit
-probit = Probit.from_formula
-from statsmodels.discrete.discrete_model import Poisson
-poisson = Poisson.from_formula
-from statsmodels.discrete.discrete_model import NegativeBinomial
-negativebinomial = NegativeBinomial.from_formula
-from statsmodels.regression.quantile_regression import QuantReg
-quantreg = QuantReg.from_formula
-from statsmodels.duration.hazard_regression import PHReg
-phreg = PHReg.from_formula
-from statsmodels.genmod.generalized_estimating_equations import (GEE,
-     OrdinalGEE, NominalGEE)
-gee = GEE.from_formula
-ordinal_gee = OrdinalGEE.from_formula
-nominal_gee = NominalGEE.from_formula
+import statsmodels.regression.linear_model as lm
+import statsmodels.discrete.discrete_model as dm
+import statsmodels.regression.mixed_linear_model as mlm
+import statsmodels.genmod.generalized_linear_model as glm
path: statsmodels/formula/api.py
text: @user1:
import as genlm not glm and then del genlm below.