예제 #1
0
def get_composite_chain():
    chain = TsForecastingChain()
    node_trend = PrimaryNode('trend_data_model')
    node_model_trend = SecondaryNode('linear', nodes_from=[node_trend])

    node_residual = PrimaryNode('residual_data_model')
    node_model_residual = SecondaryNode('linear', nodes_from=[node_residual])

    node_final = SecondaryNode(
        'linear', nodes_from=[node_model_residual, node_model_trend])
    chain.add_node(node_final)
    return chain
예제 #2
0
        data['Date'] = pd.to_datetime(data['Date'])
        dataframe = data.copy()

        chain = TsForecastingChain()
        node_trend = PrimaryNode('trend_data_model')
        node_trend.labels = ["fixed"]
        node_lstm_trend = SecondaryNode('linear', nodes_from=[node_trend])
        node_trend.labels = ["fixed"]
        node_residual = PrimaryNode('residual_data_model')
        node_ridge_residual = SecondaryNode('linear',
                                            nodes_from=[node_residual])

        node_final = SecondaryNode(
            'linear', nodes_from=[node_ridge_residual, node_lstm_trend])
        node_final.labels = ["fixed"]
        chain.add_node(node_final)
        print(f'Размер исходной цепочки {len(chain.nodes)}')

        # Заполнение пропусков
        gapfiller = ModelGapFiller(gap_value=-100.0, chain=chain)
        with_gap_array = np.array(data['gap'])
        withoutgap_arr = gapfiller.forward_filling(with_gap_array,
                                                   max_window_size=30)

        dataframe['gap'] = withoutgap_arr
        validate(parameter='Height',
                 mask='gap',
                 data=data,
                 withoutgap_arr=withoutgap_arr)

        save_path = os.path.join(folder_to_save, file)