- Mastering Machine Learning for Penetration Testing
- Chiheb Chebbi
- 127字
- 2021-06-25 21:03:09
Phishing detection with decision trees
To build the second model, we are going to use the same machine learning libraries, so there is no need to import them again. However, we are going to import the decision tree classifier from sklearn:
>>> from sklearn import tree
Create the tree.DecisionTreeClassifier() scikit-learn classifier:
classifier = tree.DecisionTreeClassifier()
Train the model:
classifier.fit(training_inputs, training_outputs)
Compute the predictions:
predictions = classifier.predict(testing_inputs)
Calculate the accuracy:
accuracy = 100.0 * accuracy_score(testing_outputs, predictions)
Then, print out the results:
print ("The accuracy of your decision tree on testing data is: " + str(accuracy))
The accuracy of the second model is approximately 90.4%, which is a great result, compared to the first model. We have now learned how to build two phishing detectors, using two machine learning techniques.