-
Notifications
You must be signed in to change notification settings - Fork 0
/
main3.py
76 lines (38 loc) · 1.52 KB
/
main3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sklearn as sc
from sklearn.preprocessing import MinMaxScaler
import pandas_datareader as web
import datetime as dt
from keras.layers import Dense, Dropout, LSTM
from keras.models import Sequential
import keras.backend as k
from keras.callbacks import EarlyStopping
from keras.utils.vis_utils import plot_model
from sklearn.model_selection import TimeSeriesSplit
from sklearn.datasets import load_breast_cancer
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
data = load_breast_cancer(as_frame=True, return_X_y=True)
df = pd.read_csv('breast-cancer_csv.csv')
X = df.iloc[:,:10]
y = df.iloc[:,9]
LabelEncoder_y = LabelEncoder()
y = LabelEncoder_y.fit_transform(y)
X = OneHotEncoder().fit_transform(X).toarray()
X_train, X_test, y_train , y_test = train_test_split(X,y, random_state=None)
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
############ machine learning
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train)
from sklearn.tree import DecisionTreeClassifier
classifier = DecisionTreeClassifier(criterion = 'entropy', random_state = 0)
classifier.fit(X_train, y_train)
prediction = classifier.predict(X_test)
from sklearn.metrics import confusion_matrix
cm2 = confusion_matrix(y_test, prediction)