Skip to content

Instantly share code, notes, and snippets.

@emjun
Last active July 22, 2020 14:53
Show Gist options
  • Save emjun/bb73f2e2ee4bc471dfeed84155992580 to your computer and use it in GitHub Desktop.
Save emjun/bb73f2e2ee4bc471dfeed84155992580 to your computer and use it in GitHub Desktop.
Proposed ideas for updating the Tea API for V1
# Goal: Provide a more OOP API that enables end-users to have multiple analyses simultaneously
# Current V0 API
variables = [
{"name": "Var0", "data type": "interval"}
{"name": "Var1", "data type": "ratio",},
]
experimental_design = {
"study type": "observational study",
"contributor variables": "Var0",
"outcome variables": "Var1",
}
assumptions = {"Type I (False Positive) Error Rate": 0.05,
"normal distribution": ["Var1"]}
# Provide data
tea.data("data.csv")
# Defie variables
tea.define_variables([
{"name": "Var0", "data type": "interval"}
{"name": "Var1", "data type": "ratio",},
]) # equivalent to tea.define_variables(variables)
# Define study design
tea.define_study_design({
"study type": "observational study",
"contributor variables": "Var0",
"outcome variables": "Var1",
}) # equivalent to tea.define_study_design(experimental_design)
# Assume
tea.assume({"Type I (False Positive) Error Rate": 0.05,
"normal distribution": ["Var1"]}) # equivalent to tea.assume(assumptions)
# Hypothesize, Execute, & obtain results
results = tea.hypothesize(["Var0", "Var1"], ["Var0~V1"])
# V1 API
# Provide data at construction
tea_obj = tea.Tea("data.csv")
# OR provide data later
tea_obj = tea.Tea()
tea_obj.add_data("data.csv")
# Declare var one at a time
tea_obj.declare_vars(name="Var0", type="interval")
tea_obj.declare_vars(name="Var1", type="ratio")
# OR all at once
tea_obj.declare_vars(name=["Var0", "Var1"], type=["interval", "ratio"])
# Specify study design
tea_obj.specify_design(type="observational study", xs=["Var0"], ys=["Var1"])
# Assume
tea_obj.assume(property="Type I (False Positive) Error Rate", value=0.05)
tea_obj.assume(property="normal distribution", var="Var1")
# Hypothesize
tea_obj.hypothesize(hypothesis="A>B",...) # String hypothesis could be syntactic sugar or kwarg
# Execute
tea_obj.brew() # provides output
"""
Notes
- declare_vars = would ideally infer types for dataset and allow end-user to override defaults/inferred types
- hypothesize = adds/keep track of hypotheses
- brew = executes valid statistical tests for all hypotheses, applying multiple comparisons when there is more than one hypothesis
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment