def build_tree(self):
     idxs = np.random.permutation(len(self.y))[:self.n_sample]
     return DecisionTreeClassifier(self.x, self.y, idxs)
knn_classifier = KnnClassifier()
knn_classifier.setKnn(knn)

#CONFIGURACAO DO SVM
svm = SvmModule()
svm_classifier = SvmClassifier()
svm_classifier.setSvm(svm)

#CONFIGURACAO DO RF
rf = RfModule()
rf_classifier = RfClassifier()
rf_classifier.setRf(rf)

#CONFIGURACAO DO RF
dt = DecisionTreeModule()
dt_classifier = DecisionTreeClassifier()
dt_classifier.setDecisionTree(dt)

#CONFIGURACAO DA NAIVEBAYES
naive_bayes = NaiveBayesModule()
naive_bayes_classifier = NaiveBayesClassifier()
naive_bayes_classifier.setNaiveBayes(naive_bayes)

#CONFIGURACAO DO LSTM
lstm = LstmModule()
lstm.setInputLength(20)
lstm.setNumberExamples(1000)
lstm_classifier = LstmClassifier()
lstm_classifier.setLstm(lstm)

#CONFIGURACAO DA REDE NEURAL
Exemplo n.º 3
0
from decision_tree_classifier import DecisionTreeClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report

if __name__ == '__main__':
    iris = load_iris()

    X_train, X_test, y_train, y_test = train_test_split(
        iris.data, iris.target,
        test_size=0.2,
        random_state=1234,
        stratify=iris.target
    )

    clf = DecisionTreeClassifier()
    clf.fit(X_train, y_train)
    clf.describe_tree()

    y_pred = clf.predict(X_test)

    print(classification_report(y_true=y_test, y_pred=y_pred, target_names=iris.target_names))