0% found this document useful (0 votes)
2 views4 pages

From Import: Dict - Keys ( ('Data', 'Target', 'Frame', 'Target - Names', 'DESCR', 'Feature - Names', 'Filename', 'Data - Module') )

The document outlines a process for loading and analyzing the breast cancer dataset using Python's scikit-learn library. It includes steps for data preparation, such as splitting the dataset into training and testing sets, standardizing the features, and training a multi-layer perceptron classifier. Finally, it presents the confusion matrix and classification report for the model's predictions on the test data.

Uploaded by

s22bothikarmohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

From Import: Dict - Keys ( ('Data', 'Target', 'Frame', 'Target - Names', 'DESCR', 'Feature - Names', 'Filename', 'Data - Module') )

The document outlines a process for loading and analyzing the breast cancer dataset using Python's scikit-learn library. It includes steps for data preparation, such as splitting the dataset into training and testing sets, standardizing the features, and training a multi-layer perceptron classifier. Finally, it presents the confusion matrix and classification report for the model's predictions on the test data.

Uploaded by

s22bothikarmohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

# ANN

from sklearn.datasets import load_breast_cancer


cancer = load_breast_cancer()

cancer.keys()
dict_keys(['data', 'target', 'frame', 'target_names', 'DESCR', 'feature_names', 'filename',
'data_module'])

cancer['data'].shape
(569, 30)

import pandas as pd
df = pd.DataFrame(cancer['data'])
df

df1 = pd.DataFrame(cancer['target'])
df1

0 0

1 0

2 0

3 0

4 0

... ...

564 0

565 0

566 0

567 0
0

568 1
569 rows × 1 columns

df2 = pd.DataFrame([cancer])
df2

df3 = pd.DataFrame(cancer['target_names'])
df3
0

0 malignant

1 benign

df4 = pd.DataFrame(cancer['feature_names'])
df4

0 mean radius

1 mean texture

2 mean perimeter

3 mean area

4 mean smoothness

5 mean compactness

6 mean concavity

7 mean concave points

8 mean symmetry

9 mean fractal dimension

10 radius error

11 texture error

12 perimeter error

13 area error
0

14 smoothness error

15 compactness error

16 concavity error

17 concave points error

18 symmetry error

19 fractal dimension error

20 worst radius

21 worst texture

22 worst perimeter

23 worst area

24 worst smoothness

25 worst compactness

26 worst concavity

27 worst concave points

28 worst symmetry

29 worst fractal dimension

x = cancer['data']
y = cancer['target']
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x,y,test_size = 0.20)
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(x_train)

x_train = scaler.transform(x_train)
x_test = scaler.transform(x_test)
from sklearn.neural_network import MLPClassifier
mlp = MLPClassifier(hidden_layer_sizes=(20,20,20))
mlp.fit(x_train,y_train)

predictions = mlp.predict(x_test)
from sklearn.metrics import classification_report,confusion_matrix
print(confusion_matrix(y_test,predictions))

[[39 3]
[ 0 72]]

print(classification_report(y_test,predictions))

You might also like