Azure databricks Issue

Rohit Kulkarni 676 Reputation points
2023-03-01T08:44:26.7866667+00:00

Hello Team,

I am trying to run the train_split data and i am getting error :

print(classification_report(ytest,ytest_predict))

TypeError: Singleton array 77 cannot be considered a valid collection.

Please advise

REgards

Rohit

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
1,903 questions
{count} votes

1 answer

Sort by: Most helpful
  1. BhargavaGunnam-MSFT 25,876 Reputation points Microsoft Employee
    2023-03-07T21:17:59.17+00:00

    Hello Rohit Kulkarni,

    Welcome to the MS Q&A platform.

    As per the error message, it seems like you are passing a singleton array (an array with only one element) as an argument to the classification_report function. This is causing the function to raise a TypeError.

    Please check the shape of your ytest and ytest_predict arrays to ensure that they have the same number of elements

    import numpy as np

    print(np.array(ytest).shape)

    print(np.array(ytest_predict).shape)

    If the shapes are the same then you can try reshaping the singleton array to be a one dimensional array using the np.ravel(), , which should be a valid collection for the classification_report function.

    print(classification_report(ytest,np.ravel(ytest_predict)))

    If you are still facing the error, please provide more context or code snippets to understand the issue better.

    0 comments No comments