This file contains hidden or 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
| ACTIVATION_RESPONSE = 1 | |
| NeuralNetwork = { | |
| transfer = function( x) return 1 / (1 + math.exp(-x / ACTIVATION_RESPONSE)) end --This is the Transfer function (in this case a sigmoid) | |
| } |
This file contains hidden or 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
| from sklearn.ensemble import RandomForestClassifier | |
| clf = RandomForestClassifier() | |
| clf.fit(X_train, y_train) | |
| y_pred = clf.predict(X_test) | |
| y_pred_probability = clf.predict_proba(X_test)[::,1] | |
| fpr, tpr, _ = metrics.roc_curve(y_test, y_pred_probability) | |
| auc = metrics.roc_auc_score(y_test, y_pred_probability) | |
| plt.plot(fpr,tpr,label="RandomForest, auc="+str(auc)) |
This file contains hidden or 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
| from sklearn.tree import DecisionTreeClassifier | |
| clf = DecisionTreeClassifier() | |
| clf.fit(X_train, y_train) | |
| y_pred = clf.predict(X_test) | |
| y_pred_probability = clf.predict_proba(X_test)[::,1] | |
| fpr, tpr, _ = metrics.roc_curve(y_test, y_pred_probability) | |
| auc = metrics.roc_auc_score(y_test, y_pred_probability) | |
| plt.plot(fpr,tpr,label="DecisionTree, auc="+str(auc)) |
This file contains hidden or 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
| # Accuracy | |
| print("Accuracy", metrics.accuracy_score(y_test, y_pred)) | |
| #AUC Curve | |
| y_pred_probability = clf.predict_proba(X_test)[::,1] | |
| fpr, tpr, _ = metrics.roc_curve(y_test, y_pred_probability) | |
| auc = metrics.roc_auc_score(y_test, y_pred_probability) | |
| plt.plot(fpr,tpr,label="data 1, auc="+str(auc)) | |
| plt.legend(loc=4) | |
| plt.show() |
This file contains hidden or 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
| # Carregando Breast Cancer Dataset | |
| breast_cancer = load_breast_cancer() | |
| X = breast_cancer.data | |
| y = breast_cancer.target | |
| # Separando o Dataset | |
| X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.33, random_state=44) | |
| # Criando um modelo | |
| clf = LogisticRegression(penalty='l2', C=0.1) |
This file contains hidden or 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
| from sklearn import metrics # Metricas para calcular accuracy score | |
| from sklearn.linear_model import LogisticRegression # Modelo utilizado | |
| from sklearn.model_selection import train_test_split # Separa dados de treinamento e teste | |
| from sklearn.datasets import load_breast_cancer # Carrega o dataset Breast Cancer | |
| import matplotlib.pyplot as plt # Plotagem de gráficos |