Phishing URL Detection โ€” Soft Voting Ensemble

Detects phishing URLs using a soft voting ensemble of:

  • RandomForestClassifier (300 estimators)
  • XGBClassifier (400 estimators)

Final prediction = average of both models' probabilities (threshold = 0.5).

Features Used

URL-based features: URLLength, DomainLength, HasAtSymbol, HasHyphen, HasHTTPS, NumDots, NumSlashes, HasIP

Usage

import joblib, json, numpy as np, pandas as pd, re
from urllib.parse import urlparse

rf = joblib.load("rf_model.pkl")
xgb = joblib.load("xgb_model.pkl")
scaler = joblib.load("scaler.pkl")
selector = joblib.load("selector.pkl")

def extract_url_features(url):
    return {
        "URLLength": len(url), "DomainLength": len(urlparse(url).netloc),
        "HasAtSymbol": 1 if "@" in url else 0, "HasHyphen": 1 if "-" in url else 0,
        "HasHTTPS": 1 if url.startswith("https") else 0, "NumDots": url.count("."),
        "NumSlashes": url.count("/"), "HasIP": 1 if re.search(r"\d+\.\d+\.\d+\.\d+", url) else 0
    }

def predict(url):
    features = pd.DataFrame([extract_url_features(url)])
    scaled = scaler.transform(features)
    selected = selector.transform(scaled)
    prob = (rf.predict_proba(selected)[:,1] + xgb.predict_proba(selected)[:,1]) / 2
    return "Phishing" if prob[0] > 0.5 else "Legitimate"
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support