<reponame>marshall4471/tumor_logistic_regression_pred
# -*- coding: utf-8 -*-
"""tumor_classifier.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1e-BLk-SMMjohRV9VZ02EvB_AfbehIWL3
"""

import numpy as np

import matplotlib.pyplot as plt

import pandas as pd

df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data',header=None)

df

X = df.loc[:,2:].values

y = df.loc[:, 1].values

from sklearn.preprocessing import LabelEncoder

labelencoder_y = LabelEncoder()

y = labelencoder_y.fit_transform(y)



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, random_state= 1)

from sklearn.preprocessing import StandardScaler

from sklearn.decomposition import PCA

from sklearn.linear_model import LogisticRegression

from sklearn.pipeline import make_pipeline

from sklearn.model_selection import learning_curve

pipe_lr = make_pipeline(StandardScaler(),
                       PCA(n_components=2),
                           LogisticRegression(random_state=1,
                                              solver='lbfgs'))

pipe_lr.fit(X_train, y_train)

y_pred = pipe_lr.predict(X_test)

print('Test Accurracy: %.3f' % pipe_lr.score(X_test, y_test))

from sklearn.metrics import confusion_matrix

pipe_lr.fit(X_train, y_train)

y_pred = pipe_lr.predict(X_test)

confmat = confusion_matrix(y_true=y_test, y_pred=y_pred)

print(confmat)

fig, ax =plt.subplots(figsize=(9.5, 9.5))
ax.matshow(confmat, cmap=plt.cm.Blues, alpha=0.30)
for i in range(confmat.shape[0]):
  for j in range(confmat.shape[1]):
    ax.text(x=j, y=i,
            s=confmat[i, j],
            va='center', ha='center')
    plt.xlabel('Predicted label')
    plt.ylabel('True Label')
# -*- coding: utf-8 -*-
"""tumor_classifier.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1e-BLk-SMMjohRV9VZ02EvB_AfbehIWL3
"""

import numpy as np

import matplotlib.pyplot as plt

import pandas as pd

df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data',header=None)

df

X = df.loc[:,2:].values

y = df.loc[:, 1].values

from sklearn.preprocessing import LabelEncoder

labelencoder_y = LabelEncoder()

y = labelencoder_y.fit_transform(y)



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, random_state= 1)

from sklearn.preprocessing import StandardScaler

from sklearn.decomposition import PCA

from sklearn.linear_model import LogisticRegression

from sklearn.pipeline import make_pipeline

from sklearn.model_selection import learning_curve

pipe_lr = make_pipeline(StandardScaler(),
                       PCA(n_components=2),
                           LogisticRegression(random_state=1,
                                              solver='lbfgs'))

pipe_lr.fit(X_train, y_train)

y_pred = pipe_lr.predict(X_test)

print('Test Accurracy: %.3f' % pipe_lr.score(X_test, y_test))

from sklearn.metrics import confusion_matrix

pipe_lr.fit(X_train, y_train)

y_pred = pipe_lr.predict(X_test)

confmat = confusion_matrix(y_true=y_test, y_pred=y_pred)

print(confmat)

fig, ax =plt.subplots(figsize=(9.5, 9.5))
ax.matshow(confmat, cmap=plt.cm.Blues, alpha=0.30)
for i in range(confmat.shape[0]):
  for j in range(confmat.shape[1]):
    ax.text(x=j, y=i,
            s=confmat[i, j],
            va='center', ha='center')
    plt.xlabel('Predicted label')
    plt.ylabel('True Label')
# -*- coding: utf-8 -*- tumor_classifier.ipynb  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1e-BLk-SMMjohRV9VZ02EvB_AfbehIWL3