Repository: VowpalWabbit/estimators (language: python)

Issue:
[RLOS2021]Make the library a proper python package 
Since the package is not structured with a `setup.py` it is hard to install and consume. We would like to be able to install it like so:
```
python -m pip install git+https://github.com/VowpalWabbit/estimators.git
```


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2d981b1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+#Jupyter notebook checkpoints
+**/.ipynb_checkpoints/*
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+*.egg-info
+
+# Python build artifacts
+build/
+dist/
+
+#ignored examples files
+examples/*.log
+
+# Editors
+.vscode/
+.idea/
+
+# Type checking
+.mypy_cache
+
+.coverage
diff --git a/estimators/__init__.py b/estimators/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/basic-usage.py b/estimators/basic-usage.py
similarity index 96%
rename from basic-usage.py
rename to estimators/basic-usage.py
index 51221ac..de7383f 100644
--- a/basic-usage.py
+++ b/estimators/basic-usage.py
@@ -1,9 +1,9 @@
 import argparse, os, gzip
-import cressieread
-import ips_snips
-import mle
-import ds_parse
-import cats_utils
+from contextual_bandits import cressieread
+from contextual_bandits import ips_snips
+from contextual_bandits import mle
+from utils import ds_parse
+from contextual_bandits import cats_utils
 
 
 def compute_estimates(log_fp, cats_transformer=None):
diff --git a/estimators/contextual_bandits/__init__.py b/estimators/contextual_bandits/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/cats_utils.py b/estimators/contextual_bandits/cats_utils.py
similarity index 100%
rename from cats_utils.py
rename to estimators/contextual_bandits/cats_utils.py
diff --git a/cressieread.py b/estimators/contextual_bandits/cressieread.py
similarity index 100%
rename from cressieread.py
rename to estimators/contextual_bandits/cressieread.py
diff --git a/ips_snips.py b/estimators/contextual_bandits/ips_snips.py
similarity index 100%
rename from ips_snips.py
rename to estimators/contextual_bandits/ips_snips.py
diff --git a/mle.py b/estimators/contextual_bandits/mle.py
similarity index 100%
rename from mle.py
rename to estimators/contextual_bandits/mle.py
diff --git a/estimators/slates/__init__.py b/estimators/slates/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pseudo_inverse.py b/estimators/slates/pseudo_inverse.py
similarity index 100%
rename from pseudo_inverse.py
rename to estimators/slates/pseudo_inverse.py
diff --git a/estimators/utils/__init__.py b/estimators/utils/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/ds_parse.py b/estimators/utils/ds_parse.py
similarity index 100%
rename from ds_parse.py
rename to estimators/utils/ds_parse.py
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..e694753
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,25 @@
+import setuptools
+
+with open("README.md", "r") as f:
+    long_description = f.read()
+
+setuptools.setup(
+    name="vw-estimators",
+    version="0.0.1",
+    description="Python package of estimators to perform off-policy evaluation",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://github.com/VowpalWabbit/estimators.git",
+    license="BSD 3-Clause License",
+    classifiers=[
+        "Intended Audience :: Science/Research",
+        "License :: OSI Approved :: BSD License",
+        "Programming Language :: Python :: 3.6",
+        "Operating System :: OS Independent",
+        "Topic :: Scientific/Engineering"
+    ],
+    packages=["estimators", "estimators.contextual_bandits", "estimators.slates", "estimators.utils"],
+    install_requires= ['scipy>=0.9'],
+    tests_require=['pytest'],
+    python_requires=">=3.6",
+)
\ No newline at end of file


Test patch:
diff --git a/estimators/test/__init__.py b/estimators/test/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/test/test_pi.py b/estimators/test/test_pi.py
similarity index 96%
rename from test/test_pi.py
rename to estimators/test/test_pi.py
index f9d3838..1fe09e5 100644
--- a/test/test_pi.py
+++ b/estimators/test/test_pi.py
@@ -1,9 +1,9 @@
 import os, sys
 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-import pseudo_inverse
-import ips_snips
-import cats_utils
+from slates import pseudo_inverse
+from contextual_bandits import ips_snips
+from contextual_bandits import cats_utils
 
 def test_single_slot_pi_equivalent_to_ips():
     """PI should be equivalent to IPS when there is only a single slot"""