--- language: - en license: mit library_name: keras tags: - cybersecurity - phishing-detection - url-classification - binary-classification - defensive-security - tabular-classification --- # PhishLens MLP PhishLens MLP is a compact binary classifier for identifying phishing-like URL strings from lexical and structural signals. It is the deployment-oriented model from the `main` branch of the [phishing-detection-rnn-cnn](https://github.com/frangelbarrera/phishing-detection-rnn-cnn) project. The model is designed for **offline URL-string analysis**. It does not browse to the submitted URL, resolve DNS, inspect page content, follow redirects, validate certificates, or query an external reputation service. The model output is a risk signal for research and defensive education, not a security verdict. Try the interactive demo in the [PhishLens Space](https://huggingface.co/spaces/frangelbarrera/phishlens). ## Model summary The classifier receives 49 deterministic features extracted from a URL string, standardizes them with the bundled `StandardScaler`, and applies a small multilayer perceptron: ```text 49 standardized features → Dense(64, ReLU) → Dense(32, ReLU) → Dense(1, Sigmoid) ``` Dropout and L2 regularization are used during training. Inference uses the trained weights in `my_model.keras` and the fitted scaler in `scaler.pkl`. ## Intended use This model is intended for academic experimentation, defensive-security education, offline feature-engineering demonstrations, and reproducible comparison with the original CNN+LSTM thesis implementation. It can be used as one component in a larger analysis pipeline where predictions are reviewed alongside other signals. ## Out-of-scope use Do not use this model as an autonomous blocking, takedown, fraud, identity, employment, credit, or law-enforcement decision system. Do not open suspicious URLs to verify a prediction. The model cannot detect phishing pages hosted on legitimate domains when the URL string itself does not contain informative signals, and it cannot assess a website's live content or infrastructure. ## Evaluation The reported metrics were calculated on a held-out 20% test split with stratification and `random_state=42`. The decision threshold was tuned on the test evaluation procedure documented by the source project and is included in `metrics.json`. | Metric | Value | | --- | ---: | | Accuracy | 89.94% | | ROC-AUC | 0.965 | | Average precision | 0.965 | | F1 score | 0.900 | | Brier score | 0.072 | | Decision threshold | 0.499 | The confusion matrix is provided in `metrics.json`. These results should not be interpreted as production performance: dataset composition, sampling, label quality, temporal drift, and domain shift can materially affect outcomes. ## Features The 49 features describe URL shape and token patterns, including lengths, punctuation counts, digit ratios, hostname structure, subdomain depth, IP-address patterns, punycode, ports, URL shorteners, path extensions, suspicious terms, and top-level-domain indicators. The canonical order is stored in `feature_names.json`. Five original dataset features were removed from the deployment-oriented branch because they require curated brand lists or live network context: `random_domain`, `domain_in_brand`, `brand_in_subdomain`, `brand_in_path`, and `nb_external_redirection`. This keeps training and inference consistent and avoids network requests. ## Repository contents | File | Description | | --- | --- | | `my_model.keras` | Trained Keras model weights and architecture metadata | | `scaler.pkl` | StandardScaler fitted on the training features | | `feature_names.json` | Canonical feature order used by the model | | `metrics.json` | Evaluation metrics, threshold, curves, and confusion matrix | | `training_metadata.json` | Training configuration, versions, architecture, and metrics digest | | `SHA256SUMS` | Checksums for the source artifacts | | `LICENSE` | MIT license | ## Reproducibility The complete training and inference pipeline is maintained in the [GitHub repository](https://github.com/frangelbarrera/phishing-detection-rnn-cnn). The model artifacts in this repository correspond to the improved `main` branch. The defended academic implementation is preserved in the [`thesis-original` branch](https://github.com/frangelbarrera/phishing-detection-rnn-cnn/tree/thesis-original), which uses a CNN+LSTM hybrid with 55 features. The Space provides a browser-based demonstration. Its URL parser and feature extractor are implemented in JavaScript so that the public demo can run as a free static Space; the model weights and scaler are the corresponding exported artifacts from this repository. ## Ethical considerations Phishing detection has asymmetric costs. False negatives can expose users to harm, while false positives can block legitimate resources. Any deployment should measure both error types on representative, current data, provide an appeal or review path, protect submitted inputs, and monitor performance drift. This model is published to support transparent defensive research rather than automated surveillance or indiscriminate blocking. ## License MIT. The model, source artifacts, and dataset usage remain subject to the terms and provenance described in the source repository.