Question: # Import packages and functions import numpy as np import pandas as pd from sklearn import metrics from sklearn.model _ selection import train _ test

# Import packages and functions
import numpy as np
import pandas as pd
from sklearn import metrics
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
# Load the breast cancer dataset
cancer = pd.read_csv('WisconsinBreastCancerDatabase.csv')
# Select input and output features
X = cancer.drop(columns=['ID', 'Diagnosis', 'Symmetry se'])
y = cancer[['Diagnosis']]
# Split the data into train and test datasets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=123)
# Initialize a multilayer perceptron classifier with default parameters and
# random_state set to 78
modelPerceptron = MLPClassifier(hidden_layer_sizes=(50,), activation='relu', solver='adam', alpha=0.01, random_state=78, max_iter=2000)
# Fit multilayer perceptron classifier to X_train and y_train
modelPerceptron.fit(X_train, y_train.values.ravel())
# Print R-squared score for training data
trainScore = modelPerceptron.score(X_train, y_train)
print(trainScore)
# Print R-squared score for testing data
testScore = modelPerceptron.score(X_test, y_test)
modelPerceptron = MLPClassifier(random_state=78) initializes a multilayer perceptron classifier. The .fit() method applies the model to the given input and output features. The .score() method returns the R-squared score.
Not all tests passed.
Output differs. See highlights below.
Your output
0.89047619047619040.9222222222222223
Expected output
0.93333333333333330.9222222222222223
what am I doing wrong?

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 Programming Questions!