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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started