<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
from sklearn.model_selection import train_test_split

base = pd.read_csv('/content/drive/My Drive/Deep Learning/Iris/original.csv')
previsores = base.iloc[:, 0:4].values
classe = base.iloc[:, 4].values
from keras.utils import np_utils
from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
classe = labelencoder.fit_transform(classe)
classe_dummy = np_utils.to_categorical(classe)
previsores_treinamento, previsores_teste, classe_treinamento, classe_teste = train_test_split(previsores, classe_dummy, test_size=0.25)
classificador = Sequential()
classificador.add(Dense(units = 4, activation = 'relu', input_dim = 4))
classificador.add(Dense(units = 4, activation = 'relu'))
classificador.add(Dense(units = 3, activation = 'softmax'))
classificador.compile(optimizer = 'adam', loss = 'categorical_crossentropy',
                      metrics = ['categorical_accuracy'])
classificador.fit(previsores_treinamento, classe_treinamento, batch_size = 10,
                  epochs = 1000)
resultado = classificador.evaluate(previsores_teste, classe_teste)
previsoes = classificador.predict(previsores_teste)
previsoes = (previsoes >0.5)
previsoes

#analisar com matriz de confusao
from sklearn.metrics import confusion_matrix
import numpy as np
classe_teste2 = [np.argmax(t) for t in classe_teste]
previsoes2 = [np.argmax(t) for t in previsoes]
matriz = confusion_matrix(previsoes2,classe_teste2)
matriz<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0982256020278834, 'fraction_numerical': 0.01394169835234474, 'mean_word_length': 6.483412322274882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '287303', 'license': 'MIT', 'n_tokens_mistral': 550, 'n_tokens_neox': 540, 'n_words': 112, 'path': 'classificar_iris/iris_simples.ipynb', 'repo_name': 'thiago1590/Deep_Learning', 'size': '1578'}