Question: Hi, I need help for the below code. I had found the code for the below question in Chegg here, but after I had written

Hi, I need help for the below code. I had found the code for the below question in Chegg here, but after I had written the code, my result gave me the below error.

Code that found in Chegg:

from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer

class BC_data: """ class to import the breast cancer dataset from sklearn """ def __init__(self): x, y = load_breast_cancer(return_X_y= True) self.x_train = None self.x_test = None self.y_train = None self.y_test = None #TODO: Split the data into training and test data (use train_test_split sklearn) # such that the test data size is 25% of total number of observations # No need to rescale the data. Use the data as is. # your code here data = BC_data() data.x_train, data.x_test, data.y_train, data.y_test = train_test_split(data.x, data.y, test_size=0.25, random_state=0)

After submission, the error listed below:

NameError Traceback (most recent call last)  in  Traceback Redacted NameError: name 'data' is not defined

Please help me on the code. Thank you so much.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!