السلام عليكم
انا عمل نموذج لتصنيف مرض القلب باستخدم الشبكه الاعصبيه وده الكود
وده البيانات الانا شغل علها
x = heart.drop(['target'] , axis=1)
y = heart['target']
x_traing , x_test , y_traing , y_test = train_test_split(x , y ,test_size=0.25,random_state=44,shuffle=True)
#print(f"X taring shape is: {x_traing.shape}")
#print(f"X test shape is: {x_test.shape}")
#print(f"Y taring shape is: {y_traing.shape}")
#print(f"Y test shape is: {y_test.shape}")
kerasmodle = keras.models.Sequential([
keras.layers.Dense(8, activation='tanh'),
keras.layers.Dense(128,activation='tanh'),
keras.layers.Dense(64,activation='tanh'),
keras.layers.Dense(1,activation='sigmoid'),
])
myoptimizer = tf.keras.optimizers.AdamW(
learning_rate=0.001,
weight_decay=0.004,
beta_1=0.9,
beta_2=0.999,
epsilon=1e-07,
amsgrad=False,
clipnorm=None,
clipvalue=None,
global_clipnorm=None,
use_ema=False,
ema_momentum=0.99,
ema_overwrite_frequency=None,
loss_scale_factor=None,
gradient_accumulation_steps=None,
name='Adamw',
)
kerasmodle.compile(optimizer=myoptimizer,loss='binary_crossentropy',metrics=['accuracy'])
#Trinag
trinag_modle = kerasmodle.fit(x_traing,y_traing,
validation_data=(x_test,y_test),
epochs=100,
batch_size=10000,
verbose=1,
callbacks=tf.keras.callbacks.EarlyStopping(
patience=10,
monitor='val_accuracy',
restore_best_weights=True,
))
#print(kerasmodle.summary())
y_pred = kerasmodle.predict(x_test)
moduleloos,modleaccuracy = kerasmodle.evaluate(x_test,y_test)
print(f"modle loss is: {moduleloos}")
print(f"modle accuracy is : {modleaccuracy}")
وده الloss و accoracy
modle loss is: 0.5819184184074402
modle accuracy is : 0.744966447353363
فا انا عاوز اعرف هل كده النموذج كويس ؟
heart.db