[Python] Getting this error when trying to fit my pipeline: TypeError: fit() missing 1...

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to fit my data using my pipeline but I get the mentioned error (TypeError: fit() missing 1 required positional argument: 'X')

    This is the code:

    normalizer = Normalizer()
    kmeans = KMeans(n_clusters=10)

    steps = [('Normalizer', normalizer), ('KMeans', kmeans)]

    pipeline = Pipeline(steps)
    pipeline = Pipeline.fit(X)

    labels_companies = pipeline.predict(X)


    However, when I use make_pipeline it just works perfectly.

    normalizer = Normalizer()
    kmeans = KMeans(n_clusters=10)

    pipeline = make_pipeline(normalizer, kmeans)
    pipeline = pipeline.fit(X)

    labels_companies = pipeline.predict(X)


    What am I missing? I don't understand why I'm getting this error!

    X is a df with shape (60, 963)

    • I tried using .fit_transform but the predictions are just wrong.
    • I looked into sklearn documentation but everything seems to be according to syntaxis.

    Continue reading...

Compartilhe esta Página