-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.txt
30 lines (30 loc) · 1.12 KB
/
code.txt
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
import tensorflow as tf
import numpy as np
import pandas as pd
import os
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
from keras.layers.convolutional import Conv1D,MaxPooling1D
abc=os.path.join('/Users/aadishesh/Desktop/', 'zs_aad.csv')
data= pd.read_csv(abc, error_bad_lines=False)
data = np.array(data)
features = data[:,:1]
dataset = np.delete(data,0,axis=1)
features = np.where(features=='S',0,features)
features = np.where(features=='Z',1,features)
print(features)
X_train, X_test,Y_train,Y_test = train_test_split(dataset,features, test_size = 0.3)
X_train = X_train.reshape(X_train.shape[0], 241, 17)
X_test = X_test.reshape(X_test.shape[0], 241, 17)
num_classes = 2
model = Sequential()
model.add(Conv1D(filters=32, kernel_size=5, input_shape=(241, 17)))
model.add(MaxPooling1D(pool_size=5 ))
model.add(Flatten())
model.add(Dense(1000, activation='relu'))
model.add(Dense(1, activation='softmax'))
model.compile(optimizer='adam',
loss='mse',
metrics=['accuracy'])
model.fit(X_train, Y_train, epochs=15,batch_size=241)