Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Import needed packages for classification # Your code here # Import packages for evaluation # Your code here # Load the dataset skySurvey =
# Import needed packages for classification # Your code here # Import packages for evaluation # Your code here # Load the dataset skySurvey = pd.read_csv('SDSS.csv') # Create a new feature from u - g skySurvey['u_g'] = skySurvey['u'] - skySurvey['g'] # Create dataframe X with features redshift and u_g X = # Your code here # Create dataframe y with feature class y = # Your code here np.random.seed(42) # Split data into training and test sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) # Initialize model with k=3 skySurveyKnn = # Your code here # Fit model using X_train and y_train # Your code here # Find the predicted classes for X_test y_pred = # Your code here # Calculate accuracy score score = # Your code here # Print accuracy score print('Accuracy score is ', end="") print('%.3f' % score)
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