Error while creating a Pipeline estimator

Discussion in 'Masters Program - Customers only' started by Abhishek Parida, May 16, 2019.

  1. Abhishek Parida

    Abhishek Parida New Member

    Joined:
    Apr 30, 2019
    Messages:
    1
    Likes Received:
    0
    Dear all,
    I was trying to execute a piece of code from the self-learning section, particularly on Pipeline in the sklear section.

    I ran into the following problem when I am trying to make a pipeline object (in blue).

    import pandas as pd
    import numpy as np

    from sklearn.pipeline import Pipeline
    from sklearn.linear_model import LogisticRegression
    from sklearn.linear_model import LinearRegression
    from sklearn.decomposition import PCA

    estimator = [('dim_reduction',PCA()), ('logReg_model',LogisticRegression()), ('linear_model',LinearRegression())]

    pipeline_estimator = Pipeline(estimator)

    It give the following error...
    ---------------------------------------------------------------------------
    TypeError Traceback (most recent call last)
    <ipython-input-17-3c68d56d97e0> in <module>
    1 # create a pipeline object and pss the chain estimators to it
    ----> 2pipeline_estimator = Pipeline(estimator)

    /opt/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py in __init__(self, steps, memory)
    117 def __init__(self, steps, memory=None):
    118 self.steps = steps
    --> 119self._validate_steps()
    120 self.memory = memory
    121

    /opt/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py in _validate_steps(self)
    165 raise TypeError("All intermediate steps should be "
    166 "transformers and implement fit and transform."
    --> 167 " '%s' (type %s) doesn't" % (t, type(t)))
    168
    169 # We allow last estimator to be None as an identity transformation

    TypeError: All intermediate steps should be transformers and implement fit and transform. 'LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
    intercept_scaling=1, max_iter=100, multi_class='warn',
    n_jobs=None, penalty='l2', random_state=None, solver='warn',
    tol=0.0001, verbose=0, warm_start=False)' (type <class 'sklearn.linear_model.logistic.LogisticRegression'>) doesn't

    I will appreciate any suggestion, hints or comments.
    Thank you in advance!

     
    #1
  2. Ovo Okpubuluku

    Joined:
    Jul 16, 2019
    Messages:
    3
    Likes Received:
    0
    I am having the same problem. Anyone with help, please?
     
    #2

Share This Page