Evalml: Component graph cannot handle duplicate column names returned

Created on 15 Jan 2021  路  1Comment  路  Source: alteryx/evalml

Was just testing test_component_graph_evaluation_plumbing and updated the following mock component code to the DummyTransformer in test_component_graph.py:


class DummyTransformer(Transformer):
    name = "Dummy Transformer"

    def __init__(self, parameters={}, random_state=0):
        super().__init__(parameters=parameters, component_obj=None, random_state=random_state)

    def fit(self, X, y):
        return self

    def transform(self, X, y):
        return X

    def fit_transform(self, X, y):
        return X

I get this error:

__________________________ test_component_graph_evaluation_plumbing __________________________

mock_transa = <MagicMock name='transform' id='5504714448'>
mock_transb = <MagicMock name='transform' id='5504714704'>
mock_transc = <MagicMock name='transform' id='4547342288'>
mock_preda = <MagicMock name='predict' id='4547342096'>
mock_predb = <MagicMock name='predict' id='4547367376'>
mock_predc = <MagicMock name='predict' id='4547392784'>
dummy_components = (<class 'evalml.tests.pipeline_tests.test_component_graph.TransformerA'>, <class 'evalml.tests.pipeline_tests.test_com...ipeline_tests.test_component_graph.EstimatorB'>, <class 'evalml.tests.pipeline_tests.test_component_graph.EstimatorC'>)

    @patch(f'{__name__}.EstimatorC.predict')
    @patch(f'{__name__}.EstimatorB.predict')
    @patch(f'{__name__}.EstimatorA.predict')
    @patch(f'{__name__}.TransformerC.transform')
    @patch(f'{__name__}.TransformerB.transform')
    @patch(f'{__name__}.TransformerA.transform')
    def test_component_graph_evaluation_plumbing(mock_transa, mock_transb, mock_transc, mock_preda, mock_predb, mock_predc, dummy_components):
        TransformerA, TransformerB, TransformerC, EstimatorA, EstimatorB, EstimatorC = dummy_components
        mock_transa.return_value = pd.DataFrame({'feature trans': [1, 0, 0, 0, 0, 0], 'feature a': np.ones(6)})
        mock_transb.return_value = pd.DataFrame({'feature b': np.ones(6) * 2})
        mock_transc.return_value = pd.DataFrame({'feature c': np.ones(6) * 3})
        mock_preda.return_value = pd.Series([0, 0, 0, 1, 0, 0])
        mock_predb.return_value = pd.Series([0, 0, 0, 0, 1, 0])
        mock_predc.return_value = pd.Series([0, 0, 0, 0, 0, 1])
        graph = {
            'transformer a': [TransformerA],
            'transformer b': [TransformerB, 'transformer a'],
            'transformer c': [TransformerC, 'transformer a', 'transformer b'],
            'estimator a': [EstimatorA],
            'estimator b': [EstimatorB, 'transformer a'],
            'estimator c': [EstimatorC, 'transformer a', 'estimator a', 'transformer b', 'estimator b', 'transformer c']
        }
        component_graph = ComponentGraph(graph)
        component_graph.instantiate({})
        X = pd.DataFrame({'feature1': np.zeros(6), 'feature2': np.zeros(6)})
        y = pd.Series(np.zeros(6))
>       component_graph.fit(X, y)

evalml/tests/pipeline_tests/test_component_graph.py:629:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
evalml/pipelines/component_graph.py:95: in fit
    self._compute_features(self.compute_order, X, y, fit=True)
evalml/pipelines/component_graph.py:214: in _compute_features
    input_x, input_y = self._consolidate_inputs(x_inputs, y_input, X, y)
evalml/pipelines/component_graph.py:266: in _consolidate_inputs
    return_x = _convert_to_woodwork_structure(return_x)
evalml/utils/gen_utils.py:323: in _convert_to_woodwork_structure
    return ww.DataTable(ww_data)
../venv/lib/python3.7/site-packages/woodwork/datatable.py:82: in __init__
    table_metadata, column_metadata, semantic_tags, make_index, column_descriptions)
../venv/lib/python3.7/site-packages/woodwork/datatable.py:1100: in _validate_params
    _check_unique_column_names(dataframe)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

dataframe =    feature1  feature2  feature1  feature2
0       0.0       0.0       0.0       0.0
1       0.0       0.0       0.0   ...  0.0       0.0       0.0       0.0
4       0.0       0.0       0.0       0.0
5       0.0       0.0       0.0       0.0

    def _check_unique_column_names(dataframe):
        if not dataframe.columns.is_unique:
>           raise IndexError('Dataframe cannot contain duplicate columns names')
E           IndexError: Dataframe cannot contain duplicate columns names

../venv/lib/python3.7/site-packages/woodwork/datatable.py:1130: IndexError

I think this is because I updated transform to return the original DF, so now we have multiple cols with the same name and data when we try to consolidate in _consolidate_inputs?
EDIT: I'm not really sure since we mock the return types 馃 Haven't dug too far!

@dsherry @chukarsten Since we were just talking about this!

bug

Most helpful comment

Edit: okay never mind, I'm silly and had my main branch in a weird state 馃槀

>All comments

Edit: okay never mind, I'm silly and had my main branch in a weird state 馃槀

Was this page helpful?
0 / 5 - 0 ratings