Created
November 12, 2023 01:59
-
-
Save celsowm/8871710b0509f76e3e906af9c1235b83 to your computer and use it in GitHub Desktop.
neural_network_tensorflow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import pandas as pd | |
# Ler o arquivo CSV | |
df = pd.read_csv('diabetes.csv') | |
# Extrair os dados para feature_set e labels | |
feature_set = df.drop('diabetico', axis=1).values | |
labels = df['diabetico'].values | |
model = tf.keras.Sequential([ | |
tf.keras.layers.Dense(4, activation='sigmoid', input_shape=(3,)), | |
tf.keras.layers.Dense(1, activation='sigmoid') | |
]) | |
model.compile(optimizer='sgd', loss='binary_crossentropy', metrics=['accuracy']) | |
model.fit(feature_set, labels, epochs=20000, batch_size=len(feature_set), verbose=0) | |
# Predição | |
single_point = tf.constant([[1, 0, 0]]) # ou [[1, 0, 0]] | |
result = model.predict(single_point) | |
limiar = 0.5 | |
resultado = 1 if result[0][0] > limiar else 0 | |
print(resultado) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment