Skip to content

Commit

Permalink
add new files
Browse files Browse the repository at this point in the history
  • Loading branch information
david26694 committed Dec 13, 2024
1 parent ed14554 commit 2b48247
Show file tree
Hide file tree
Showing 44 changed files with 138 additions and 136 deletions.
24 changes: 12 additions & 12 deletions ab_lab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from cluster_experiments.cupac import EmptyRegressor, TargetAggregation
from cluster_experiments.experiment_analysis import (
from ab_lab.cupac import EmptyRegressor, TargetAggregation
from ab_lab.experiment_analysis import (
ClusteredOLSAnalysis,
ExperimentAnalysis,
GeeExperimentAnalysis,
Expand All @@ -9,12 +9,12 @@
SyntheticControlAnalysis,
TTestClusteredAnalysis,
)
from cluster_experiments.inference.analysis_plan import AnalysisPlan
from cluster_experiments.inference.dimension import Dimension
from cluster_experiments.inference.hypothesis_test import HypothesisTest
from cluster_experiments.inference.metric import Metric, RatioMetric, SimpleMetric
from cluster_experiments.inference.variant import Variant
from cluster_experiments.perturbator import (
from ab_lab.inference.analysis_plan import AnalysisPlan
from ab_lab.inference.dimension import Dimension
from ab_lab.inference.hypothesis_test import HypothesisTest
from ab_lab.inference.metric import Metric, RatioMetric, SimpleMetric
from ab_lab.inference.variant import Variant
from ab_lab.perturbator import (
BetaRelativePerturbator,
BetaRelativePositivePerturbator,
BinaryPerturbator,
Expand All @@ -26,9 +26,9 @@
SegmentedBetaRelativePerturbator,
UniformPerturbator,
)
from cluster_experiments.power_analysis import NormalPowerAnalysis, PowerAnalysis
from cluster_experiments.power_config import PowerConfig
from cluster_experiments.random_splitter import (
from ab_lab.power_analysis import NormalPowerAnalysis, PowerAnalysis
from ab_lab.power_config import PowerConfig
from ab_lab.random_splitter import (
BalancedClusteredSplitter,
BalancedSwitchbackSplitter,
ClusteredSplitter,
Expand All @@ -40,7 +40,7 @@
StratifiedSwitchbackSplitter,
SwitchbackSplitter,
)
from cluster_experiments.washover import ConstantWashover, EmptyWashover, Washover
from ab_lab.washover import ConstantWashover, EmptyWashover, Washover

__all__ = [
"ExperimentAnalysis",
Expand Down
13 changes: 7 additions & 6 deletions ab_lab/inference/analysis_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from typing import Any, Dict, List, Optional

import pandas as pd
from cluster_experiments.experiment_analysis import ExperimentAnalysis
from cluster_experiments.inference.analysis_results import AnalysisPlanResults
from cluster_experiments.inference.dimension import Dimension
from cluster_experiments.inference.hypothesis_test import HypothesisTest
from cluster_experiments.inference.metric import Metric
from cluster_experiments.inference.variant import Variant

from ab_lab.experiment_analysis import ExperimentAnalysis
from ab_lab.inference.analysis_results import AnalysisPlanResults
from ab_lab.inference.dimension import Dimension
from ab_lab.inference.hypothesis_test import HypothesisTest
from ab_lab.inference.metric import Metric
from ab_lab.inference.variant import Variant

logger = logging.getLogger(__name__)

Expand Down
15 changes: 8 additions & 7 deletions ab_lab/inference/hypothesis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from typing import Dict, List, Optional

import pandas as pd
from cluster_experiments.cupac import CupacHandler
from cluster_experiments.experiment_analysis import ExperimentAnalysis, InferenceResults
from cluster_experiments.inference.analysis_results import AnalysisPlanResults
from cluster_experiments.inference.dimension import DefaultDimension, Dimension
from cluster_experiments.inference.metric import Metric
from cluster_experiments.inference.variant import Variant
from cluster_experiments.power_config import analysis_mapping

from ab_lab.cupac import CupacHandler
from ab_lab.experiment_analysis import ExperimentAnalysis, InferenceResults
from ab_lab.inference.analysis_results import AnalysisPlanResults
from ab_lab.inference.dimension import DefaultDimension, Dimension
from ab_lab.inference.metric import Metric
from ab_lab.inference.variant import Variant
from ab_lab.power_config import analysis_mapping


class HypothesisTest:
Expand Down
8 changes: 4 additions & 4 deletions examples/cupac_example_gbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import pandas as pd
from sklearn.ensemble import HistGradientBoostingRegressor

from cluster_experiments.experiment_analysis import GeeExperimentAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import ClusteredSplitter
from ab_lab.experiment_analysis import GeeExperimentAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import ClusteredSplitter


def generate_random_data(clusters, dates, N):
Expand Down
10 changes: 5 additions & 5 deletions examples/cupac_example_target_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import numpy as np
import pandas as pd

from cluster_experiments.cupac import TargetAggregation
from cluster_experiments.experiment_analysis import GeeExperimentAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import ClusteredSplitter
from ab_lab.cupac import TargetAggregation
from ab_lab.experiment_analysis import GeeExperimentAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import ClusteredSplitter


def generate_random_data(clusters, dates, N, n_users=1000):
Expand Down
8 changes: 4 additions & 4 deletions examples/long_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import numpy as np
import pandas as pd

from cluster_experiments.experiment_analysis import GeeExperimentAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import ClusteredSplitter
from ab_lab.experiment_analysis import GeeExperimentAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import ClusteredSplitter


def generate_random_data(clusters, dates, N):
Expand Down
8 changes: 4 additions & 4 deletions examples/parallel_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import numpy as np
import pandas as pd

from cluster_experiments.experiment_analysis import GeeExperimentAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import ClusteredSplitter
from ab_lab.experiment_analysis import GeeExperimentAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import ClusteredSplitter


def generate_random_data(clusters, dates, N):
Expand Down
8 changes: 4 additions & 4 deletions examples/short_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import numpy as np
import pandas as pd

from cluster_experiments.experiment_analysis import GeeExperimentAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import ClusteredSplitter
from ab_lab.experiment_analysis import GeeExperimentAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import ClusteredSplitter


def generate_random_data(clusters, dates, N):
Expand Down
4 changes: 2 additions & 2 deletions examples/short_example_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import pandas as pd

from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.power_config import PowerConfig
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.power_config import PowerConfig


def generate_random_data(clusters, dates, N):
Expand Down
2 changes: 1 addition & 1 deletion examples/short_example_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pandas as pd

from cluster_experiments.power_analysis import PowerAnalysis
from ab_lab.power_analysis import PowerAnalysis


def generate_random_data(clusters, dates, N):
Expand Down
8 changes: 4 additions & 4 deletions examples/short_example_paired_ttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import numpy as np
import pandas as pd

from cluster_experiments.experiment_analysis import PairedTTestClusteredAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import StratifiedSwitchbackSplitter
from ab_lab.experiment_analysis import PairedTTestClusteredAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import StratifiedSwitchbackSplitter


def generate_random_data(clusters, dates, N):
Expand Down
10 changes: 5 additions & 5 deletions examples/short_example_synthetic_control.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from cluster_experiments.experiment_analysis import SyntheticControlAnalysis
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysisWithPreExperimentData
from cluster_experiments.random_splitter import FixedSizeClusteredSplitter
from cluster_experiments.synthetic_control_utils import generate_synthetic_control_data
from ab_lab.experiment_analysis import SyntheticControlAnalysis
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysisWithPreExperimentData
from ab_lab.random_splitter import FixedSizeClusteredSplitter
from ab_lab.synthetic_control_utils import generate_synthetic_control_data

df = generate_synthetic_control_data(10, "2022-01-01", "2022-01-30")

Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import pytest

from cluster_experiments.experiment_analysis import (
from ab_lab.experiment_analysis import (
ClusteredOLSAnalysis,
ConfidenceInterval,
ExperimentAnalysis,
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/test_hypothesis.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pandas as pd
import pytest

from cluster_experiments.experiment_analysis import (
from ab_lab.experiment_analysis import (
ClusteredOLSAnalysis,
GeeExperimentAnalysis,
MLMExperimentAnalysis,
OLSAnalysis,
SyntheticControlAnalysis,
TTestClusteredAnalysis,
)
from cluster_experiments.synthetic_control_utils import generate_synthetic_control_data
from ab_lab.synthetic_control_utils import generate_synthetic_control_data
from tests.utils import generate_clustered_data


Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/test_synthetic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pandas as pd
import pytest

from cluster_experiments.experiment_analysis import SyntheticControlAnalysis
from cluster_experiments.synthetic_control_utils import get_w
from ab_lab.experiment_analysis import SyntheticControlAnalysis
from ab_lab.synthetic_control_utils import get_w


def generate_2_clusters_data(N, start_date, end_date):
Expand Down
2 changes: 1 addition & 1 deletion tests/cupac/test_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pandas as pd

from cluster_experiments.cupac import TargetAggregation
from ab_lab.cupac import TargetAggregation


def split_x_y(binary_df_agg: pd.DataFrame) -> Tuple[pd.DataFrame, pd.Series]:
Expand Down
2 changes: 1 addition & 1 deletion tests/cupac/test_cupac_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from sklearn.ensemble import HistGradientBoostingRegressor

from cluster_experiments.cupac import CupacHandler, TargetAggregation
from ab_lab.cupac import CupacHandler, TargetAggregation
from tests.utils import generate_random_data

N = 1_000
Expand Down
12 changes: 6 additions & 6 deletions tests/inference/test_analysis_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import pandas as pd
import pytest

from cluster_experiments.inference.analysis_plan import AnalysisPlan
from cluster_experiments.inference.analysis_results import AnalysisPlanResults
from cluster_experiments.inference.dimension import Dimension
from cluster_experiments.inference.hypothesis_test import HypothesisTest
from cluster_experiments.inference.metric import SimpleMetric
from cluster_experiments.inference.variant import Variant
from ab_lab.inference.analysis_plan import AnalysisPlan
from ab_lab.inference.analysis_results import AnalysisPlanResults
from ab_lab.inference.dimension import Dimension
from ab_lab.inference.hypothesis_test import HypothesisTest
from ab_lab.inference.metric import SimpleMetric
from ab_lab.inference.variant import Variant

# Set up constants for the data
NUM_ORDERS = 10000
Expand Down
2 changes: 1 addition & 1 deletion tests/inference/test_analysis_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
import pytest

from cluster_experiments.inference.analysis_results import AnalysisPlanResults
from ab_lab.inference.analysis_results import AnalysisPlanResults


def test_analysis_plan_results_initialization():
Expand Down
2 changes: 1 addition & 1 deletion tests/inference/test_dimension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from cluster_experiments.inference.dimension import DefaultDimension, Dimension
from ab_lab.inference.dimension import DefaultDimension, Dimension


def test_dimension_initialization():
Expand Down
14 changes: 7 additions & 7 deletions tests/inference/test_hypothesis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import pandas as pd
import pytest

from cluster_experiments import TargetAggregation
from cluster_experiments.experiment_analysis import ClusteredOLSAnalysis
from cluster_experiments.inference.dimension import Dimension
from cluster_experiments.inference.hypothesis_test import HypothesisTest
from cluster_experiments.inference.metric import SimpleMetric
from cluster_experiments.inference.variant import Variant
from cluster_experiments.power_config import analysis_mapping
from ab_lab import TargetAggregation
from ab_lab.experiment_analysis import ClusteredOLSAnalysis
from ab_lab.inference.dimension import Dimension
from ab_lab.inference.hypothesis_test import HypothesisTest
from ab_lab.inference.metric import SimpleMetric
from ab_lab.inference.variant import Variant
from ab_lab.power_config import analysis_mapping

# Set up constants for the data
NUM_ORDERS = 10000
Expand Down
2 changes: 1 addition & 1 deletion tests/inference/test_metric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
import pytest

from cluster_experiments.inference.metric import Metric, RatioMetric, SimpleMetric
from ab_lab.inference.metric import Metric, RatioMetric, SimpleMetric

# Sample DataFrame for testing
sample_data = pd.DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion tests/inference/test_variant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from cluster_experiments.inference.variant import Variant
from ab_lab.inference.variant import Variant


def test_variant_initialization():
Expand Down
4 changes: 2 additions & 2 deletions tests/perturbator/test_perturbator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import pytest

from cluster_experiments.perturbator import (
from ab_lab.perturbator import (
BetaRelativePerturbator,
BetaRelativePositivePerturbator,
BinaryPerturbator,
Expand All @@ -13,7 +13,7 @@
SegmentedBetaRelativePerturbator,
UniformPerturbator,
)
from cluster_experiments.power_config import PowerConfig
from ab_lab.power_config import PowerConfig


def test_binary_perturbator_from_config():
Expand Down
10 changes: 5 additions & 5 deletions tests/power_analysis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import pandas as pd
import pytest

from cluster_experiments.cupac import TargetAggregation
from cluster_experiments.experiment_analysis import (
from ab_lab.cupac import TargetAggregation
from ab_lab.experiment_analysis import (
ClusteredOLSAnalysis,
GeeExperimentAnalysis,
MLMExperimentAnalysis,
)
from cluster_experiments.perturbator import ConstantPerturbator
from cluster_experiments.power_analysis import PowerAnalysis
from cluster_experiments.random_splitter import (
from ab_lab.perturbator import ConstantPerturbator
from ab_lab.power_analysis import PowerAnalysis
from ab_lab.random_splitter import (
ClusteredSplitter,
StratifiedSwitchbackSplitter,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/power_analysis/test_multivariate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from cluster_experiments import (
from ab_lab import (
ConstantPerturbator,
NonClusteredSplitter,
OLSAnalysis,
Expand Down
Loading

0 comments on commit 2b48247

Please sign in to comment.