コード例 #1
0
ファイル: conftest.py プロジェクト: noahsa/scikit-hts
def mv_tree(hierarchical_mv_data):
    hier = {
        "total": ["CH", "SLU", "BT", "OTHER"],
        "CH": ["CH-07", "CH-02", "CH-08", "CH-05", "CH-01"],
        "SLU": ["SLU-15", "SLU-01", "SLU-19", "SLU-07", "SLU-02"],
        "BT": ["BT-01", "BT-03"],
        "OTHER": ["WF-01", "CBD-13"],
    }
    exogenous = {
        k: ["precipitation", "temp"]
        for k in hierarchical_mv_data.columns
        if k not in ["precipitation", "temp"]
    }
    return HierarchyTree.from_nodes(hier, hierarchical_mv_data, exogenous=exogenous)
コード例 #2
0
ファイル: conftest.py プロジェクト: vtoliveira/scikit-hts
def mv_tree(hierarchical_mv_data):
    hier = {
        'total': ['CH', 'SLU', 'BT', 'OTHER'],
        'CH': ['CH-07', 'CH-02', 'CH-08', 'CH-05', 'CH-01'],
        'SLU': ['SLU-15', 'SLU-01', 'SLU-19', 'SLU-07', 'SLU-02'],
        'BT': ['BT-01', 'BT-03'],
        'OTHER': ['WF-01', 'CBD-13']
    }
    exogenous = {
        k: ['precipitation', 'temp']
        for k in hierarchical_mv_data.columns
        if k not in ['precipitation', 'temp']
    }
    return HierarchyTree.from_nodes(hier,
                                    hierarchical_mv_data,
                                    exogenous=exogenous)
コード例 #3
0
def test_create_hierarchical_sine_data_tree(hierarchical_sine_data):
    hier = {
        "total": ["a", "b", "c"],
        "a": ["aa", "ab"],
        "aa": ["aaa", "aab"],
        "b": ["ba", "bb"],
        "c": ["ca", "cb", "cc", "cd"],
    }
    ht = HierarchyTree.from_nodes(hier, hierarchical_sine_data)
    assert isinstance(ht.to_pandas(), pandas.DataFrame)
    assert ht.key == "total"
    assert len(ht.children) == 3
    for c in ht.children:
        if c.key == "a" or c.key == "b":
            assert len(c.children) == 2
        if c.key == "c":
            assert len(c.children) == 4
コード例 #4
0
def test_create_hierarchical_sine_data_tree(hierarchical_sine_data):
    hier = {
        'total': ['a', 'b', 'c'],
        'a': ['aa', 'ab'],
        'aa': ['aaa', 'aab'],
        'b': ['ba', 'bb'],
        'c': ['ca', 'cb', 'cc', 'cd']
    }
    ht = HierarchyTree.from_nodes(hier, hierarchical_sine_data)
    assert isinstance(ht.to_pandas(), pandas.DataFrame)
    assert ht.key == 'total'
    assert len(ht.children) == 3
    for c in ht.children:
        if c.key == 'a' or c.key == 'b':
            assert len(c.children) == 2
        if c.key == 'c':
            assert len(c.children) == 4
コード例 #5
0
def test_create_hierarchical_sine_data_tree(hierarchical_sine_data):
    hier = {
        "total": ["a", "b", "c"],
        "a": ["a_x", "a_y"],
        "b": ["b_x", "b_y"],
        "c": ["c_x", "c_y"],
        "a_x": ["a_x_1", "a_x_2"],
        "a_y": ["a_y_1", "a_y_2"],
        "b_x": ["b_x_1", "b_x_2"],
        "b_y": ["b_y_1", "b_y_2"],
        "c_x": ["c_x_1", "c_x_2"],
        "c_y": ["c_y_1", "c_y_2"],
    }
    ht = HierarchyTree.from_nodes(hier, hierarchical_sine_data)
    assert isinstance(ht.to_pandas(), pandas.DataFrame)
    assert ht.key == "total"
    assert len(ht.children) == 3
    for c in ht.children:
        if c.key == "a" or c.key == "b" or c.key == "c":
            assert len(c.children) == 2
        if (c.key == "a_x" or c.key == "b_x" or c.key == "c_x"
                or c.key == "a_y" or c.key == "b_y" or c.key == "c_y"):
            assert len(c.children) == 4
コード例 #6
0
ファイル: regressor.py プロジェクト: amankhandelia/incedo-hts
    def __init_hts(self,
                   nodes: Optional[NodesT] = None,
                   df: Optional[pandas.DataFrame] = None,
                   tree: Optional[HierarchyTree] = None,
                   root: str = 'root',
                   exogenous: Optional[List[str]] = None):

        if not nodes and not df:
            if not tree:
                raise InvalidArgumentException(
                    'Either nodes and df must be passed, or a pre-built hierarchy tree'
                )
            else:
                self.nodes = tree
        else:
            self.nodes = HierarchyTree.from_nodes(nodes=nodes,
                                                  df=df,
                                                  exogenous=exogenous,
                                                  root=root)
        self.exogenous = exogenous
        self.sum_mat = to_sum_mat(self.nodes)
        self._set_model_instance()
        self._init_revision()
コード例 #7
0
ファイル: conftest.py プロジェクト: vtoliveira/scikit-hts
def uv_tree(sine_hier, hierarchical_sine_data):
    hsd = hierarchical_sine_data.resample('1H').apply(sum).head(400)
    return HierarchyTree.from_nodes(sine_hier, hsd)