<jupyter_start><jupyter_text>Transfomação de variáveis categóricas<jupyter_code>previsores = base.iloc[:, 0:14].values
classe = base.iloc[:, 14].values
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.compose import ColumnTransformer
labelencoder_previsores = LabelEncoder()
previsores[:, 1] = labelencoder_previsores.fit_transform(previsores[:,1])
previsores[:, 3] = labelencoder_previsores.fit_transform(previsores[:,3])
previsores[:, 5] = labelencoder_previsores.fit_transform(previsores[:,5])
previsores[:, 6] = labelencoder_previsores.fit_transform(previsores[:,6])
previsores[:, 7] = labelencoder_previsores.fit_transform(previsores[:,7])
previsores[:, 8] = labelencoder_previsores.fit_transform(previsores[:,8])
previsores[:, 9] = labelencoder_previsores.fit_transform(previsores[:,9])
previsores[:, 13] = labelencoder_previsores.fit_transform(previsores[:,13])
onehotencorder = ColumnTransformer(transformers=[("OneHot", OneHotEncoder(), [1,3,5,6,7,8,9,13])],remainder='passthrough')
previsores = onehotencorder.fit_transform(previsores).toarray()
labelencorder_classe = LabelEncoder()
classe = labelencorder_classe.fit_transform(classe)<jupyter_output><empty_output><jupyter_text>Escalonamento dos valoers numéricos<jupyter_code>from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
previsores = scaler.fit_transform(previsores)
from sklearn.model_selection import train_test_split
previsores_treinamento, previsores_teste, classe_treinamento, classe_teste =  train_test_split(previsores, classe, test_size=0.15, random_state=0)<jupyter_output><empty_output><jupyter_text>Treinamento tensor flow<jupyter_code>from sklearn.neural_network import MLPClassifier
classificador = MLPClassifier(verbose=True, max_iter=1000, tol=0.000010)
classificador.fit(previsores_treinamento, classe_treinamento)<jupyter_output>Iteration 1, loss = 0.38044674
Iteration 2, loss = 0.32651168
Iteration 3, loss = 0.31621319
Iteration 4, loss = 0.31044233
Iteration 5, loss = 0.30630636
Iteration 6, loss = 0.30250458
Iteration 7, loss = 0.30001322
Iteration 8, loss = 0.29701525
Iteration 9, loss = 0.29494038
Iteration 10, loss = 0.29326693
Iteration 11, loss = 0.29099984
Iteration 12, loss = 0.29037263
Iteration 13, loss = 0.28707287
Iteration 14, loss = 0.28632038
Iteration 15, loss = 0.28467447
Iteration 16, loss = 0.28360786
Iteration 17, loss = 0.28207526
Iteration 18, loss = 0.28086725
Iteration 19, loss = 0.27981511
Iteration 20, loss = 0.27813679
Iteration 21, loss = 0.27652957
Iteration 22, loss = 0.27627031
Iteration 23, loss = 0.27469060
Iteration 24, loss = 0.27378048
Iteration 25, loss = 0.27341736
Iteration 26, loss = 0.27173806
Iteration 27, loss = 0.27066445
Iteration 28, loss = 0.27095509
Iteration 29, loss = 0.26909547
Iteration 30, loss = 0.26891002
Iteration 31, loss = 0.26741528
Iteration 32, los[...]<jupyter_text>Resultado da previsão<jupyter_code>previsoes = classificador.predict(previsores_teste)
from sklearn.metrics import confusion_matrix, accuracy_score
precisao = accuracy_score(classe_teste, previsoes)
print(precisao)
matriz = confusion_matrix(classe_teste, previsoes)
print(matriz)<jupyter_output>[[3392  367]
 [ 455  670]]
{'fraction_non_alphanumeric': 0.10758706467661691, 'fraction_numerical': 0.12251243781094527, 'mean_word_length': 7.886740331491713, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '392643', 'license': 'MIT', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1183, 'n_words': 232, 'path': 'rede_neural_census.ipynb', 'repo_name': 'andrade-lcs/python_machine_learning', 'size': '3216'}