Last active
February 21, 2019 13:08
-
-
Save Niranjankumar-c/727c2f90ca72d1659bee1d84cd92ef34 to your computer and use it in GitHub Desktop.
Importing required libraries and data to start building the perceptron model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import packages | |
import sklearn.datasets | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from sklearn.model_selection import train_test_split | |
#load the breast cancer data | |
breast_cancer = sklearn.datasets.load_breast_cancer() | |
#convert the data to pandas dataframe. | |
data = pd.DataFrame(breast_cancer.data, columns = breast_cancer.feature_names) | |
data["class"] = breast_cancer.target | |
data.head() | |
data.describe() | |
#plotting a graph to see class imbalance | |
data['class'].value_counts().plot(kind = "barh") | |
plt.xlabel("Count") | |
plt.ylabel("Classes") | |
plt.show() | |
from sklearn.preprocessing import MinMaxScaler | |
#perform scaling on the data. | |
X = data.drop("class", axis = 1) | |
Y = data["class"] | |
mnscaler = MinMaxScaler() | |
X = mnscaler.fit_transform(X) | |
X = pd.DataFrame(X, columns=data.drop("class",axis = 1).columns) | |
#train test split. | |
X_train, X_test, Y_train, Y_test = train_test_split(X,Y, test_size = 0.1, stratify = Y, random_state = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment