<jupyter_start><jupyter_text>Loading data.- Load data and shuffle it with specific seeding.<jupyter_code>df = pd.read_csv("dataset.csv",index_col=0)
df = sklearn.utils.shuffle(df)
X = df.drop("Result",axis=1).values
X = preprocessing.scale(X)
y = df['Result'].values
df.head()<jupyter_output><empty_output><jupyter_text>Evalution metrics  - Specifying evaluation metrics for classification models - Using 10 fold-cross-validation for evaluting<jupyter_code>scoring = {'accuracy': 'accuracy',
           'recall': 'recall',
           'precision': 'precision',
           'f1': 'f1'}
fold_count=10<jupyter_output><empty_output><jupyter_text>Classication models for phishing detection:  Descision Tree<jupyter_code>dtree_clf=DecisionTreeClassifier()
cross_val_scores = cross_validate(dtree_clf, X, y, cv=fold_count, scoring=scoring)
dtree_score = mean_score(cross_val_scores)
print(dtree_score)<jupyter_output>{'fit_time': 0.02145226001739502, 'score_time': 0.0037374973297119142, 'test_accuracy': 0.9659887246037655, 'test_recall': 0.9714145813536058, 'test_precision': 0.9676815772041456, 'test_f1': 0.9695318553822136}<jupyter_text>Random Forest<jupyter_code>rforest_clf=RandomForestClassifier()
cross_val_scores = cross_validate(rforest_clf, X, y, cv=fold_count, scoring=scoring)
rforest_clf_score = mean_score(cross_val_scores)
print(rforest_clf_score)<jupyter_output>{'fit_time': 0.4361262321472168, 'score_time': 0.021941876411437987, 'test_accuracy': 0.9726827751548527, 'test_recall': 0.9814847956921128, 'test_precision': 0.9698521059240438, 'test_f1': 0.9756226033690053}<jupyter_text>Ada_Booster<jupyter_code>adaboost_clf=AdaBoostClassifier()
cross_val_scores = cross_validate(adaboost_clf, X, y, cv=fold_count, scoring=scoring)
adaboost_clf_score = mean_score(cross_val_scores)
print(adaboost_clf_score)<jupyter_output>{'fit_time': 0.33651931285858155, 'score_time': 0.016766834259033202, 'test_accuracy': 0.9369532701103811, 'test_recall': 0.9543622637525075, 'test_precision': 0.9339432018487536, 'test_f1': 0.9440090232748538}<jupyter_text>Gradient Boosting With XGBoost<jupyter_code>XGB_clf=XGBClassifier()
cross_val_scores = cross_validate(XGB_clf, X, y, cv=fold_count, scoring=scoring)
XGB_clf_score= mean_score(cross_val_scores)
print(XGB_clf_score)<jupyter_output>{'fit_time': 0.5060725927352905, 'score_time': 0.0062372684478759766, 'test_accuracy': 0.9712358750705734, 'test_recall': 0.9790470911202618, 'test_precision': 0.9696243951193955, 'test_f1': 0.9742930356745975}<jupyter_text>Gradient_Booster<jupyter_code>gradientBooster_clf=GradientBoostingClassifier()
cross_val_scores = cross_validate(gradientBooster_clf,X, y, cv=fold_count, scoring=scoring)
gradientBooster_clf_score= mean_score(cross_val_scores)
print(gradientBooster_clf_score)<jupyter_output>{'fit_time': 0.8918887376785278, 'score_time': 0.0052986621856689455, 'test_accuracy': 0.9486214232528454, 'test_recall': 0.9624812585788195, 'test_precision': 0.9462347462776315, 'test_f1': 0.9542607542640835}<jupyter_text>Histogram-Based Gradient Boosting<jupyter_code>histGradientBooster_clf = HistGradientBoostingClassifier()
cross_val_scores = cross_validate(histGradientBooster_clf,X, y, cv=fold_count, scoring=scoring)
histGradientBooster_clf_score= mean_score(cross_val_scores)
print(histGradientBooster_clf_score)<jupyter_output>{'fit_time': 0.5056329250335694, 'score_time': 0.005911087989807129, 'test_accuracy': 0.9686116043301449, 'test_recall': 0.9766107063668039, 'test_precision': 0.9673711778832252, 'test_f1': 0.9719463292594973}<jupyter_text>LightGBM for Classification<jupyter_code>LGBM_clf = LGBMClassifier()
cross_val_scores = cross_validate(LGBM_clf,X, y, cv=fold_count, scoring=scoring)
LGBM_clf_score= mean_score(cross_val_scores)
print(LGBM_clf_score)<jupyter_output>{'fit_time': 0.281274151802063, 'score_time': 0.004857301712036133, 'test_accuracy': 0.9685211065925884, 'test_recall': 0.9767733079928202, 'test_precision': 0.9670633398533888, 'test_f1': 0.9718731387465702}<jupyter_text>Gradient Boosting with CatBoost<jupyter_code>catBoost_classifier = CatBoostClassifier(verbose=0, n_estimators=100)
cross_val_scores = cross_validate(catBoost_classifier,X, y, cv=fold_count, scoring=scoring)
catBoost_classifier_score= mean_score(cross_val_scores)
print(catBoost_classifier_score)<jupyter_output>{'fit_time': 0.4080570936203003, 'score_time': 0.01025078296661377, 'test_accuracy': 0.9715968023041739, 'test_recall': 0.9805083940449792, 'test_precision': 0.9688890089359475, 'test_f1': 0.9746458794259351}<jupyter_text>KNN<jupyter_code>KNeighbors_clf=KNeighborsClassifier(3)
cross_val_scores = cross_validate(KNeighbors_clf, X, y, cv=fold_count, scoring=scoring)
KNeighbors_clf_score = mean_score(cross_val_scores)
print(KNeighbors_clf_score)<jupyter_output>{'fit_time': 0.11297237873077393, 'score_time': 0.3535628795623779, 'test_accuracy': 0.9527809643818579, 'test_recall': 0.9629682715658324, 'test_precision': 0.9527832046787947, 'test_f1': 0.95782786394066}<jupyter_text>Logistic Regrression<jupyter_code>logistic_clf=LogisticRegression(random_state=1)
cross_val_scores = cross_validate(logistic_clf, X, y, cv=fold_count, scoring=scoring)
logistic_clf_score = mean_score(cross_val_scores)
print(logistic_clf_score)<jupyter_output>{'fit_time': 0.08097140789031983, 'score_time': 0.006414532661437988, 'test_accuracy': 0.9265502851578802, 'test_recall': 0.9439684299440397, 'test_precision': 0.9257009824145145, 'test_f1': 0.9347047945148483}<jupyter_text>NN<jupyter_code>neural_clf=MLPClassifier(hidden_layer_sizes=(33,),max_iter=500)
cross_val_scores = cross_validate(neural_clf, X, y, cv=fold_count, scoring=scoring)
neural_clf_score = mean_score(cross_val_scores)
print(neural_clf_score)<jupyter_output>{'fit_time': 9.0885178565979, 'score_time': 0.006925249099731445, 'test_accuracy': 0.9698791454264276, 'test_recall': 0.9787234716503009, 'test_precision': 0.9676053403687239, 'test_f1': 0.9731127503135303}<jupyter_text>SVM<jupyter_code>###linear
linear_clf = svm.SVC(kernel='linear')
cross_val_scores = cross_validate(linear_clf, X, y, cv=fold_count, scoring=scoring)
linear_svc_clf_score = mean_score(cross_val_scores)
print(linear_svc_clf_score)
###poly
poly_clf = svm.SVC(kernel='poly')
cross_val_scores = cross_validate(poly_clf, X, y, cv=fold_count, scoring=scoring)
poly_svc_clf_score = mean_score(cross_val_scores)
print(poly_svc_clf_score)
###rbf
rbf_clf = svm.SVC(kernel='rbf')
cross_val_scores = cross_validate(rbf_clf, X, y, cv=fold_count, scoring=scoring)
rbf_svc_clf_score = mean_score(cross_val_scores)
print(rbf_svc_clf_score)
###sigmoid
sigmoid_clf = svm.SVC(kernel='sigmoid')
cross_val_scores = cross_validate(sigmoid_clf, X, y, cv=fold_count, scoring=scoring)
sigmoid_svc_clf_score = mean_score(cross_val_scores)
print(sigmoid_svc_clf_score)<jupyter_output>{'fit_time': 1.6475388288497925, 'score_time': 0.05397987365722656, 'test_accuracy': 0.9277262647999803, 'test_recall': 0.945592070531095, 'test_precision': 0.9262681624188114, 'test_f1': 0.9357793221750376}
{'fit_time': 1.0482579469680786, 'score_time': 0.07420728206634522, 'test_accuracy': 0.9492547437670297, 'test_recall': 0.9688163868651675, 'test_precision': 0.9417793952178888, 'test_f1': 0.9550833558973665}
{'fit_time': 1.3415402889251709, 'score_time': 0.1033292531967163, 'test_accuracy': 0.9521492803547904, 'test_recall': 0.968815331010453, 'test_precision': 0.9465803137802874, 'test_f1': 0.9575433423537307}
{'fit_time': 1.3446074724197388, 'score_time': 0.109696364402771, 'test_accuracy': 0.8274983021446165, 'test_recall': 0.8465151515151514, 'test_precision': 0.8443119026086775, 'test_f1': 0.8453050000657976}
{'fraction_non_alphanumeric': 0.12059247607812296, 'fraction_numerical': 0.20749770612137894, 'mean_word_length': 12.649373881932021, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '574870', 'license': 'MIT', 'n_tokens_mistral': 4194, 'n_tokens_neox': 3161, 'n_words': 373, 'path': 'All_Classifair.ipynb', 'repo_name': 'fafal-abnir/phishing_detection', 'size': '7629'}