I don't know what's wrong with my code.. I repeatedly get that value error message.. I want to know how to correct my code. And actually python said error occurs at " history=model.fit(X_train, Y_train, ". I want to correct my code.. 'interpolation' is data that I made from excel file, which is linear interpolated.

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
feature=interpolation.iloc[:,0:5]
feature_n=scaler.fit_transform(feature)

adm=interpolation.iloc[:,6]
y=[]
for i in range(0,len(adm)):
  if adm[i]<=-1:
    y.insert(i,1)
  else:
    y.insert(i,0)

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from sklearn.model_selection import train_test_split
from keras.callbacks import EarlyStopping

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

seed = 123
tf.random.set_seed(seed)

X=pd.DataFrame(feature_n)
Y=pd.DataFrame(y)

X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.25,random_state=seed)
X_train,X_val,Y_train,Y_val=train_test_split(X_train,Y_train,test_size=0.5,random_state=seed)


model = Sequential()
model.add(Dense(6, input_dim=6, activation='sigmoid'))
model.add(Dense(6, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
early_stopping_callback=EarlyStopping(monitor='val_loss', patience=50)
history=model.fit(X_train, Y_train,
                  validation_data=(X_val,Y_val),
                  epochs=500, batch_size=64,callbacks=[early_stopping_callback])

print(f'\nTest Accuracy: {model.evaluate(X_test, Y_test)[1]}')


y_vloss = history.history['val_loss']
y_loss = history.history['loss']

x_len = np.arange(len(y_loss))
plt.plot(x_len, y_vloss, marker = '.', c = 'red', markersize = 3, label = 'Testset_loss')
plt.plot(x_len, y_loss, marker = '.', c = 'blue', markersize = 3, label = 'Trainset_loss')

plt.legend(loc = 'upper right')
plt.grid()
plt.xlabel('epoch')
plt.ylabel('loss')
plt.show()
0

There are 0 answers