faizath commited on
Commit
9dcd2d8
·
verified ·
1 Parent(s): 023b024

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_scratch.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b488e776208c4e017681c3ca34761aded2b8b05eea2a316347704490bf48fd50
3
+ size 398019
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_scratch.npz": {
29
+ "bytes": 398019,
30
+ "sha256": "b488e776208c4e017681c3ca34761aded2b8b05eea2a316347704490bf48fd50"
31
+ },
32
+ "metrics.json": {
33
+ "bytes": 2923,
34
+ "sha256": "bc4ab5b668429e75a62b014e4d2cb1d9a4d640658e6f58480544b18ef432cf38"
35
+ }
36
+ },
37
+ "is_scratch": true,
38
+ "knn_k": 20,
39
+ "knn_reference_rows": 10000,
40
+ "library_version": "1.0.0",
41
+ "model_key": "knn_scratch",
42
+ "model_name": "KNN (from scratch)",
43
+ "parameter_count": 500001,
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_scratch": {
14
+ "accuracy": 0.9804494141946511,
15
+ "average_precision_phishing": 0.9674091116816042,
16
+ "baseline_accuracy": 0.9248,
17
+ "confusion_matrix": [
18
+ [
19
+ 1634,
20
+ 518
21
+ ],
22
+ [
23
+ 31,
24
+ 25898
25
+ ]
26
+ ],
27
+ "family": "knn",
28
+ "is_scratch": true,
29
+ "legitimate_f1": 0.9895118922533194,
30
+ "legitimate_precision": 0.9803906723198061,
31
+ "legitimate_recall": 0.998804427475028,
32
+ "lift_over_baseline": 0.05564941419465119,
33
+ "name": "KNN (from scratch)",
34
+ "phishing_f1": 0.856169766832591,
35
+ "phishing_precision": 0.9813813813813814,
36
+ "phishing_recall": 0.7592936802973977,
37
+ "predict_seconds": 5.637033897000947,
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_scratch": {
50
+ "accuracy": 0.9855774367009722,
51
+ "average_precision_phishing": 0.9533724979602588,
52
+ "baseline_accuracy": 0.9248,
53
+ "confusion_matrix": [
54
+ [
55
+ 1795,
56
+ 357
57
+ ],
58
+ [
59
+ 48,
60
+ 25881
61
+ ]
62
+ ],
63
+ "family": "knn",
64
+ "is_scratch": true,
65
+ "legitimate_f1": 0.9922364713324515,
66
+ "legitimate_precision": 0.9863937800137206,
67
+ "legitimate_recall": 0.9981487909290756,
68
+ "lift_over_baseline": 0.06077743670097224,
69
+ "name": "KNN (from scratch)",
70
+ "phishing_f1": 0.8986232790988736,
71
+ "phishing_precision": 0.9739555073250136,
72
+ "phishing_recall": 0.8341078066914498,
73
+ "predict_seconds": 5.352090013009729,
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,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "byte_identical": [
3
+ "model/fitted_stats.json",
4
+ "model/knn_scratch.npz"
5
+ ],
6
+ "modules": [
7
+ {
8
+ "module": "phiusiil/__init__.py",
9
+ "sha256": null,
10
+ "source": "rewritten"
11
+ },
12
+ {
13
+ "edited": false,
14
+ "module": "phiusiil/schema.py",
15
+ "sha256": "f2b55eb2116e9c8584a46b86f887d4b61f72e002472d30373b3e3782f07fa641",
16
+ "source_sha256": "f2b55eb2116e9c8584a46b86f887d4b61f72e002472d30373b3e3782f07fa641"
17
+ },
18
+ {
19
+ "edited": false,
20
+ "module": "phiusiil/features/__init__.py",
21
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
22
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
23
+ },
24
+ {
25
+ "edited": false,
26
+ "module": "phiusiil/features/url_features.py",
27
+ "sha256": "f56770d221335cb6bfb65ff3e54de87f02f4db3d653a0b67db74d3fc3179e5fe",
28
+ "source_sha256": "f56770d221335cb6bfb65ff3e54de87f02f4db3d653a0b67db74d3fc3179e5fe"
29
+ },
30
+ {
31
+ "edited": false,
32
+ "module": "phiusiil/preprocess/__init__.py",
33
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
34
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
35
+ },
36
+ {
37
+ "edited": false,
38
+ "module": "phiusiil/preprocess/stats.py",
39
+ "sha256": "e7a2a69950bffdc0dccb867bb4b186a9bd5f0c85a5028987782f7254093b56c4",
40
+ "source_sha256": "e7a2a69950bffdc0dccb867bb4b186a9bd5f0c85a5028987782f7254093b56c4"
41
+ },
42
+ {
43
+ "edited": true,
44
+ "module": "phiusiil/preprocess/scaler.py",
45
+ "sha256": "e15f4153108cb3a3e3043cac3b46b7eee82e9e0008ff44252896e2f787d3a400",
46
+ "source_sha256": "51275d0c18b2e295f0a75451f1776a329ad23469f9ebab3cba19067ae774bed2"
47
+ },
48
+ {
49
+ "edited": true,
50
+ "module": "phiusiil/preprocess/transformer.py",
51
+ "sha256": "6610f94b36eb5981ac05cb74bac52777431f622fcbd234837497514a5a0fb377",
52
+ "source_sha256": "0c0c95dd05239ac027bb986f45818855316af00dbbea5ccf0884d1f869ae18a5"
53
+ },
54
+ {
55
+ "edited": false,
56
+ "module": "phiusiil/models/__init__.py",
57
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
58
+ "source_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
59
+ },
60
+ {
61
+ "edited": true,
62
+ "module": "phiusiil/models/base.py",
63
+ "sha256": "aad4a59b713993800e533c2febaa82927ec13bf9c4edaf52438d92029c74fe84",
64
+ "source_sha256": "cfd0dbe9fa0687187a4b02bb6cfbc924fcfadc9bc9150c6a85ce5132fd735cc1"
65
+ },
66
+ {
67
+ "edited": true,
68
+ "module": "phiusiil/models/knn_scratch.py",
69
+ "sha256": "58da366c9ef507fccf88da05449322a3d7c285f608110120fc5b315970b1e9f0",
70
+ "source_sha256": "1c51fb823df54d846992ffa5d176e046af8f472ffb35c01d7f28045673e2695d"
71
+ }
72
+ ],
73
+ "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.",
74
+ "reserialised": [],
75
+ "source_artifacts": {
76
+ "fitted_stats.json": "9d8d3804ec079bef9f47d4a63abe365d1a69830a5b7348d53359d00e0cfd5e65",
77
+ "golden_row.json": "2a2e64148dbb0c2d298eae5e4071ca496e642fcb98a06cc2d7cfbb3d3900ea27",
78
+ "metrics.json": "4ed0d21483c05158a52523ee3be4fdd323da29f4cfb7f51a71f5612b7765bc8f",
79
+ "models/knn_scratch.npz": "b488e776208c4e017681c3ca34761aded2b8b05eea2a316347704490bf48fd50"
80
+ },
81
+ "source_git_sha": "b9fbbe0054ebffe4caabcc833f3c42a8dbc72001",
82
+ "source_repo": "https://github.com/fetiai/phishing-url-classifier"
83
+ }