A classifier for detecting soft 404 pages
Project description
A “soft” 404 page is a page that is served with 200 status, but is really a page that says that content is not available.
Installation
pip install soft-404
Usage
The easiest way is to use the soft404.probability function:
>>> import soft404 >>> soft404.probability('<h1>Page not found</h1>') 0.9736860086882132
You can also create a classifier explicitly:
>>> from soft404 import Soft404Classifier >>> clf = Soft404Classifier() >>> clf.predict('<h1>Page not found</h1>') 0.9736860086882132
Development
Classifier is trained on 37486 pages from 6660 domains, with 404 page ratio of about 1/3. With 10-fold cross-validation, PR AUC (average precision) is 0.990 ± 0.006, and ROC AUC is 0.994 ± 0.004.
Getting data for training
Install dev requirements:
pip install -r requirements_dev.txt
Run the crawler for a while (results will appear in pages.jl.gz file):
cd crawler scrapy crawl spider -o pages.jl -t gzip -s JOBDIR=job
Training
First, extract text and structure from html:
./soft404/convert_to_text.py pages.jl.gz items
This will produce two files, items.meta.jl.gz and items.items.jl.gz. Next, train the classifier:
./soft404/train.py items
Vectorizer takes a while to run, but it’s result is cached (the filename where it is cached will be printed on the next run). If you are happy with results, save the classifier:
./soft404/train.py items --save soft404/clf.joblib
License
License is MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file soft-404-0.3.0.tar.gz
.
File metadata
- Download URL: soft-404-0.3.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a28e5a06373ae7656ac0a162151e774f1131b991e6cfd6741d0e429e6234714e |
|
MD5 | 4f0fd444ddeefcc9f843fe429a570db0 |
|
BLAKE2b-256 | 6f46184a158f958d5e61b2e0b86be4508cb8e6c79a6c40625778913d86313a61 |
File details
Details for the file soft_404-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: soft_404-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dd0ec0598afb3a2133d695c4f515894ad0b5a661b8c77e93abbc3bf26b19b1c |
|
MD5 | 1db822ba2c9da9f91c3f1ebc590bca95 |
|
BLAKE2b-256 | 19c0ce99afe741750c7d6e23e6e88a94db08318da2d5eeabc5eb732e8920eee9 |