faizath commited on
Commit
9402fbe
·
verified ·
1 Parent(s): dee0c53

feat(model): add the trained artifact and its fitted preprocessing state

Browse files

Weights on their own classify nothing here. They were fitted on
standardised inputs and the statistics producing that standardisation
cannot be recovered from them, so shipping one without the other would
ship something unusable.

That state is JSON rather than a pickled transformer because a pickled
estimator arrives with a fit method attached, and refitting at serving
time is the defect this pipeline exists to prevent.

model/fitted_stats.json ADDED
The diff for this file is too large to render. See raw diff
 
model/golden_row.json ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "prediction": 1,
3
+ "raw": {
4
+ "Bank": 0.0,
5
+ "CharContinuationRate": null,
6
+ "Crypto": 0.0,
7
+ "DegitRatioInURL": 0.0,
8
+ "Domain": null,
9
+ "DomainLength": 25.0,
10
+ "DomainTitleMatchScore": null,
11
+ "HasCopyrightInfo": 1.0,
12
+ "HasDescription": 0.0,
13
+ "HasExternalFormSubmit": 0.0,
14
+ "HasFavicon": 1.0,
15
+ "HasHiddenFields": 1.0,
16
+ "HasObfuscation": 0.0,
17
+ "HasPasswordField": 0.0,
18
+ "HasSocialNet": 1.0,
19
+ "HasSubmitButton": 1.0,
20
+ "HasTitle": null,
21
+ "IsDomainIP": 0.0,
22
+ "IsHTTPS": 1.0,
23
+ "IsResponsive": 1.0,
24
+ "LargestLineLength": null,
25
+ "LetterRatioInURL": 0.562,
26
+ "LineOfCode": null,
27
+ "NoOfAmpersandInURL": null,
28
+ "NoOfCSS": 20.0,
29
+ "NoOfDegitsInURL": null,
30
+ "NoOfEmptyRef": 14.0,
31
+ "NoOfEqualsInURL": 0.0,
32
+ "NoOfExternalRef": null,
33
+ "NoOfImage": null,
34
+ "NoOfJS": 27.0,
35
+ "NoOfLettersInURL": 18.0,
36
+ "NoOfObfuscatedChar": 0.0,
37
+ "NoOfOtherSpecialCharsInURL": 2.0,
38
+ "NoOfPopup": null,
39
+ "NoOfQMarkInURL": 0.0,
40
+ "NoOfSelfRedirect": 0.0,
41
+ "NoOfSelfRef": 2.0,
42
+ "NoOfSubDomain": null,
43
+ "NoOfURLRedirect": null,
44
+ "NoOfiFrame": 0.0,
45
+ "ObfuscationRatio": null,
46
+ "Pay": 0.0,
47
+ "Robots": 1.0,
48
+ "SpacialCharRatioInURL": null,
49
+ "TLD": "uk",
50
+ "TLDLegitimateProb": 0.028555,
51
+ "TLDLength": 2.0,
52
+ "Title": "citroencarclborg",
53
+ "URL": "https://www.citroencarclub.org.uk",
54
+ "URLCharProb": 0.061898722,
55
+ "URLLength": null,
56
+ "URLTitleMatchScore": null
57
+ },
58
+ "score": 0.0,
59
+ "vector": [
60
+ 0.9458264112472534,
61
+ 1.0816572904586792,
62
+ 0.0,
63
+ -0.5169346332550049,
64
+ -1.0161705017089844,
65
+ 0.5501726865768433,
66
+ -1.451346755027771,
67
+ 2.004185438156128,
68
+ 0.0,
69
+ 0.0,
70
+ 0.0,
71
+ 0.18957722187042236,
72
+ 0.1772976815700531,
73
+ -0.19320730865001678,
74
+ -0.20799125730991364,
75
+ 0.0,
76
+ 0.0,
77
+ 0.0,
78
+ -0.14323538541793823,
79
+ 1.1197621822357178,
80
+ 1.0,
81
+ -0.23217405378818512,
82
+ -0.2989865839481354,
83
+ 1.0,
84
+ -1.7388476133346558,
85
+ -1.8001145124435425,
86
+ 1.0,
87
+ 1.0,
88
+ 1.0,
89
+ 0.0,
90
+ 0.0,
91
+ 0.0,
92
+ -0.21410752832889557,
93
+ -0.4983856976032257,
94
+ 0.0,
95
+ 1.0,
96
+ 1.0,
97
+ 1.0,
98
+ 0.0,
99
+ 0.0,
100
+ 0.0,
101
+ 0.0,
102
+ 1.0,
103
+ -0.24477894604206085,
104
+ 1.5860761404037476,
105
+ 1.2351645231246948,
106
+ -0.9924272298812866,
107
+ 2.4717586040496826,
108
+ -0.2637692391872406
109
+ ]
110
+ }
model/knn_sklearn.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a34564d384384b7708c1561ff0f5d3ce2863d117865afad7ea5e119b300aa06
3
+ size 2040804
model/manifest.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "artifact_schema_version": "v1",
3
+ "demoted_features": [
4
+ "Bank",
5
+ "HasExternalFormSubmit",
6
+ "HasFavicon",
7
+ "HasHiddenFields",
8
+ "HasSubmitButton",
9
+ "LargestLineLength",
10
+ "NoOfExternalRef",
11
+ "NoOfPopup",
12
+ "NoOfSelfRef",
13
+ "NoOfiFrame",
14
+ "Pay",
15
+ "Robots"
16
+ ],
17
+ "family": "knn",
18
+ "feature_count": 49,
19
+ "files": {
20
+ "fitted_stats.json": {
21
+ "bytes": 676974,
22
+ "sha256": "9d8d3804ec079bef9f47d4a63abe365d1a69830a5b7348d53359d00e0cfd5e65"
23
+ },
24
+ "golden_row.json": {
25
+ "bytes": 2344,
26
+ "sha256": "17c9bdda53a0567ecac0969f3b1f3a391589a40728117e3f55c42394b86d1732"
27
+ },
28
+ "knn_sklearn.joblib": {
29
+ "bytes": 2040804,
30
+ "sha256": "7a34564d384384b7708c1561ff0f5d3ce2863d117865afad7ea5e119b300aa06"
31
+ },
32
+ "metrics.json": {
33
+ "bytes": 2929,
34
+ "sha256": "29dae9342898d4e816e80e04da7b3660bad84d22ae97bd3b21c952885cbc3fe8"
35
+ }
36
+ },
37
+ "is_scratch": false,
38
+ "knn_k": 20,
39
+ "knn_reference_rows": 10000,
40
+ "library_version": "1.0.0",
41
+ "model_key": "knn_sklearn",
42
+ "model_name": "KNN (scikit-learn)",
43
+ "parameter_count": 500002,
44
+ "profile": "corrected",
45
+ "random_state": 42,
46
+ "source_git_sha": "b9fbbe0054ebffe4caabcc833f3c42a8dbc72001",
47
+ "test_size": 0.2
48
+ }
model/metrics.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "artifact_schema_version": "v1",
3
+ "baseline_accuracy": 0.9248,
4
+ "baseline_note": "A constant 'legitimate' predictor scores this. Read every accuracy against it: on its own the number cannot tell a working detector from a constant.",
5
+ "n_train": 112323,
6
+ "n_validation": 28081,
7
+ "positive_class": "phishing (label 0)",
8
+ "profiles": {
9
+ "corrected": {
10
+ "knn_k": 20,
11
+ "leaky": false,
12
+ "models": {
13
+ "knn_sklearn": {
14
+ "accuracy": 0.9807343043338912,
15
+ "average_precision_phishing": 0.9674091116816042,
16
+ "baseline_accuracy": 0.9248,
17
+ "confusion_matrix": [
18
+ [
19
+ 1643,
20
+ 509
21
+ ],
22
+ [
23
+ 32,
24
+ 25897
25
+ ]
26
+ ],
27
+ "family": "knn",
28
+ "is_scratch": false,
29
+ "legitimate_f1": 0.9896627495939619,
30
+ "legitimate_precision": 0.9807240778610922,
31
+ "legitimate_recall": 0.9987658606193837,
32
+ "lift_over_baseline": 0.05593430433389124,
33
+ "name": "KNN (scikit-learn)",
34
+ "phishing_f1": 0.8586360073164359,
35
+ "phishing_precision": 0.9808955223880597,
36
+ "phishing_recall": 0.7634758364312267,
37
+ "predict_seconds": 1.3011771459860029,
38
+ "support_legitimate": 25929,
39
+ "support_phishing": 2152
40
+ }
41
+ },
42
+ "note": "Canonical. Serving-time statistics are the training-time statistics.",
43
+ "parity_vs_sibling_implementation": 0.00035611267405006946
44
+ },
45
+ "legacy": {
46
+ "knn_k": 6,
47
+ "leaky": true,
48
+ "models": {
49
+ "knn_sklearn": {
50
+ "accuracy": 0.9862896620490723,
51
+ "average_precision_phishing": 0.9533724979602588,
52
+ "baseline_accuracy": 0.9248,
53
+ "confusion_matrix": [
54
+ [
55
+ 1837,
56
+ 315
57
+ ],
58
+ [
59
+ 70,
60
+ 25859
61
+ ]
62
+ ],
63
+ "family": "knn",
64
+ "is_scratch": false,
65
+ "legitimate_f1": 0.9926107901656336,
66
+ "legitimate_precision": 0.9879651562619394,
67
+ "legitimate_recall": 0.9973003201049019,
68
+ "lift_over_baseline": 0.06148966204907236,
69
+ "name": "KNN (scikit-learn)",
70
+ "phishing_f1": 0.9051490514905149,
71
+ "phishing_precision": 0.9632931305715784,
72
+ "phishing_recall": 0.8536245353159851,
73
+ "predict_seconds": 0.5451889800024219,
74
+ "support_legitimate": 25929,
75
+ "support_phishing": 2152
76
+ }
77
+ },
78
+ "note": "Reconstruction of the original's configuration, including standardising each split by its own mean and standard deviation. Reported for provenance only. The scaling behind these numbers does not exist at serving time and cannot be reconstructed from a single URL, so they describe a model that cannot be deployed.",
79
+ "parity_vs_sibling_implementation": 0.0022791211139204445
80
+ }
81
+ }
82
+ }
origin.json ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "byte_identical": [
3
+ "model/fitted_stats.json"
4
+ ],
5
+ "modules": [
6
+ {
7
+ "module": "phiusiil/__init__.py",
8
+ "sha256": null,
9
+ "source": "rewritten"
10
+ },
11
+ {
12
+ "edited": false,
13
+ "module": "phiusiil/schema.py",
14
+ "sha256": "f2b55eb2116e9c8584a46b86f887d4b61f72e002472d30373b3e3782f07fa641",
15
+ "source_sha256": "f2b55eb2116e9c8584a46b86f887d4b61f72e002472d30373b3e3782f07fa641"
16
+ },
17
+ {
18
+ "edited": false,
19
+ "module": "phiusiil/features/__init__.py",
20
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
21
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
22
+ },
23
+ {
24
+ "edited": false,
25
+ "module": "phiusiil/features/url_features.py",
26
+ "sha256": "f56770d221335cb6bfb65ff3e54de87f02f4db3d653a0b67db74d3fc3179e5fe",
27
+ "source_sha256": "f56770d221335cb6bfb65ff3e54de87f02f4db3d653a0b67db74d3fc3179e5fe"
28
+ },
29
+ {
30
+ "edited": false,
31
+ "module": "phiusiil/preprocess/__init__.py",
32
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
33
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
34
+ },
35
+ {
36
+ "edited": false,
37
+ "module": "phiusiil/preprocess/stats.py",
38
+ "sha256": "e7a2a69950bffdc0dccb867bb4b186a9bd5f0c85a5028987782f7254093b56c4",
39
+ "source_sha256": "e7a2a69950bffdc0dccb867bb4b186a9bd5f0c85a5028987782f7254093b56c4"
40
+ },
41
+ {
42
+ "edited": true,
43
+ "module": "phiusiil/preprocess/scaler.py",
44
+ "sha256": "e15f4153108cb3a3e3043cac3b46b7eee82e9e0008ff44252896e2f787d3a400",
45
+ "source_sha256": "51275d0c18b2e295f0a75451f1776a329ad23469f9ebab3cba19067ae774bed2"
46
+ },
47
+ {
48
+ "edited": true,
49
+ "module": "phiusiil/preprocess/transformer.py",
50
+ "sha256": "6610f94b36eb5981ac05cb74bac52777431f622fcbd234837497514a5a0fb377",
51
+ "source_sha256": "0c0c95dd05239ac027bb986f45818855316af00dbbea5ccf0884d1f869ae18a5"
52
+ },
53
+ {
54
+ "edited": false,
55
+ "module": "phiusiil/models/__init__.py",
56
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
57
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
58
+ },
59
+ {
60
+ "edited": true,
61
+ "module": "phiusiil/models/base.py",
62
+ "sha256": "aad4a59b713993800e533c2febaa82927ec13bf9c4edaf52438d92029c74fe84",
63
+ "source_sha256": "cfd0dbe9fa0687187a4b02bb6cfbc924fcfadc9bc9150c6a85ce5132fd735cc1"
64
+ },
65
+ {
66
+ "edited": true,
67
+ "module": "phiusiil/models/sk.py",
68
+ "sha256": "ba278f30245fcfae4fccddc0253149f937a0ed9732dc2b49554ab03e81df158b",
69
+ "source_sha256": "b247856c353b867173a70af6fdd94e5b6eee31758fa95ee8324182798b76a214"
70
+ }
71
+ ],
72
+ "note": "Provenance for everything copied out of the training bundle. The vendored modules were copied with the package name rewritten, so source_sha256 is the hash before that rewrite and sha256 the hash as shipped. source_artifacts records the bundle's own hashes: fitted_stats.json is byte-identical and will match, while metrics.json and golden_row.json were reduced to this one model and so will not -- the recorded hash is what they were reduced from.",
73
+ "reserialised": [
74
+ "model/knn_sklearn.joblib"
75
+ ],
76
+ "source_artifacts": {
77
+ "fitted_stats.json": "9d8d3804ec079bef9f47d4a63abe365d1a69830a5b7348d53359d00e0cfd5e65",
78
+ "golden_row.json": "2a2e64148dbb0c2d298eae5e4071ca496e642fcb98a06cc2d7cfbb3d3900ea27",
79
+ "metrics.json": "4ed0d21483c05158a52523ee3be4fdd323da29f4cfb7f51a71f5612b7765bc8f",
80
+ "models/knn_sklearn.joblib": "0c1ca136527e597c5a77dccf1dc0d6d3d61e52e3e3afa770099d48a2fc393503"
81
+ },
82
+ "source_git_sha": "b9fbbe0054ebffe4caabcc833f3c42a8dbc72001",
83
+ "source_repo": "https://github.com/fetiai/phishing-url-classifier"
84
+ }