Portable classifiers
Browse filesFiles changed (9)
- README.mdAdded+16
- classifiers.jsonAdded+506
- export_check.jsonAdded+5
- review_dnn/config.jsonAdded+12
- review_dnn/model.weights.h5Added+3
- review_dnn/vocab.jsonAdded
- tfidf_portable/tfidf_logreg_config.jsonAdded+26
- tfidf_portable/tfidf_logreg_weights.npzAdded+3
- tfidf_portable/tfidf_terms.jsonAdded
12345678910111213141516---license: apache-2.0language: entags: [text-classification, sentiment-analysis, amazon-reviews]---# Amazon review polarity classifiers
Two classifiers trained on the Amazon Review Polarity dataset (Zhang et al., 2015), labels0 = negative, 1 = positive. Input: cleaned "title. text" (lowercase, HTML and URLs removed).
- `tfidf_portable/`: TF-IDF (word 1-2-grams, sublinear TF) + logistic regression as plain files (term list JSON, NumPy weights). Test accuracy 0.9380 on the 400,000-review test split.- `review_dnn/`: Keras CNN (embedding + Conv1D kernels 3 and 5) weights, vocabulary and config. Test accuracy 0.9342.
Metrics, 5-fold cross-validation and timings: `classifiers.json`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506{
"data": {
"train_rows_raw": 3600000,
"train_rows_removed_in_test": 0,
"train_rows_removed_duplicates": 0,
"train_rows_clean": 3600000,
"test_rows": 400000,
"cv_sample": 200000,
"final_train_sample": 1000000,
"test_eval_rows": 400000,
"cv_class_counts": {
"0": 100000,
"1": 100000
},
"test_class_counts": {
"0": 200000,
"1": 200000
}
},
"machine": {
"platform": "Windows-11-10.0.26200-SP0",
"python": "3.12.6"
},
"models": {
"tfidf_logreg": {
"params": {
"max_features": 500000,
"ngram_range": [
1,
2
],
"min_df": 3,
"max_df": 0.95,
"C": 4.0,
"max_iter": 1000,
"seed": 42
},
"cv": {
"k": 5,
"seed": 42,
"folds": [
{
"accuracy": 0.9271,
"precision": 0.928686138713239,
"recall": 0.92525,
"f1": 0.926964885037319,
"macro_f1": 0.927099750498896,
"roc_auc": 0.9778334387500001,
"seconds": 35.470371400006115,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.928825,
"precision": 0.9294046963400591,
"recall": 0.92815,
"f1": 0.9287769244239862,
"macro_f1": 0.9288249675708758,
"roc_auc": 0.9779667525000001,
"seconds": 33.100827900052536,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.925425,
"precision": 0.9242159844443336,
"recall": 0.92685,
"f1": 0.9255311181566268,
"macro_f1": 0.9254248485658332,
"roc_auc": 0.97738443875,
"seconds": 33.14103190001333,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.93055,
"precision": 0.9326266077170418,
"recall": 0.92815,
"f1": 0.9303829190056134,
"macro_f1": 0.9305495999656959,
"roc_auc": 0.9783388662500001,
"seconds": 34.1310722999624,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.9239,
"precision": 0.9245793269230769,
"recall": 0.9231,
"f1": 0.9238390712570056,
"macro_f1": 0.9238999512959688,
"roc_auc": 0.9777508374999998,
"seconds": 33.133894800033886,
"n_train": 160000,
"n_val": 40000
}
],
"summary": {
"accuracy": {
"mean": 0.92716,
"sd": 0.0026412946636071963
},
"precision": {
"mean": 0.92790255082755,
"sd": 0.0035292263113757306
},
"recall": {
"mean": 0.9263,
"sd": 0.002149999999999996
},
"f1": {
"mean": 0.9270989835761103,
"sd": 0.0025837438976263234
},
"macro_f1": {
"mean": 0.927159823579454,
"sd": 0.0026412025120398524
},
"roc_auc": {
"mean": 0.9778548667500001,
"sd": 0.0003461783082014993
},
"seconds": {
"mean": 33.795439660013656,
"sd": 1.032765972743064
}
}
},
"cv_seconds": 169.04506689996924,
"fit_seconds": 182.13359199999832,
"vocabulary_size": 500000,
"predict_seconds": 44.414174400037155,
"test": {
"metrics": {
"accuracy": 0.938035,
"precision": 0.9380087194768314,
"recall": 0.938065,
"f1": 0.9380368588942332,
"macro_f1": 0.9380349999442315,
"roc_auc": 0.9826685887500002
},
"classification_report": {
"negative": {
"precision": 0.9380612836770206,
"recall": 0.938005,
"f1-score": 0.9380331409942299,
"support": 200000.0
},
"positive": {
"precision": 0.9380087194768314,
"recall": 0.938065,
"f1-score": 0.9380368588942332,
"support": 200000.0
},
"accuracy": 0.938035,
"macro avg": {
"precision": 0.938035001576926,
"recall": 0.938035,
"f1-score": 0.9380349999442315,
"support": 400000.0
},
"weighted avg": {
"precision": 0.938035001576926,
"recall": 0.938035,
"f1-score": 0.9380349999442316,
"support": 400000.0
}
},
"classification_report_text": " precision recall f1-score support\n\n negative 0.9381 0.9380 0.9380 200000\n positive 0.9380 0.9381 0.9380 200000\n\n accuracy 0.9380 400000\n macro avg 0.9380 0.9380 0.9380 400000\nweighted avg 0.9380 0.9380 0.9380 400000\n",
"confusion_matrix": [
[
187601,
12399
],
[
12387,
187613
]
]
},
"top_features": {
"negative": [
[
"not worth",
-33.13134002685547
],
[
"disappointing",
-28.9620418548584
],
[
"not",
-25.559701919555664
],
[
"2 stars",
-22.686147689819336
],
[
"not recommend",
-21.881484985351562
],
[
"disappointment",
-21.26935386657715
],
[
"awful",
-21.2116756439209
],
[
"two stars",
-21.038969039916992
],
[
"poorly",
-20.9211368560791
],
[
"horrible",
-19.031095504760742
],
[
"worst",
-18.86812400817871
],
[
"not very",
-18.684253692626953
],
[
"useless",
-18.621469497680664
],
[
"at best",
-18.3948974609375
],
[
"terrible",
-17.579355239868164
]
],
"positive": [
[
"great",
27.76874351501465
],
[
"4 stars",
20.04746437072754
],
[
"a must",
17.982744216918945
],
[
"not bad",
17.86312484741211
],
[
"not disappointed",
17.835979461669922
],
[
"excellent",
17.744455337524414
],
[
"my only",
17.331737518310547
],
[
"good",
17.178146362304688
],
[
"best",
16.079877853393555
],
[
"be disappointed",
16.032546997070312
],
[
"no problems",
14.654282569885254
],
[
"awesome",
14.313421249389648
],
[
"four stars",
14.306000709533691
],
[
"just what",
13.373373031616211
],
[
"even better",
13.221014976501465
]
]
}
},
"review_dnn": {
"config": {
"vocab_size": 30000,
"seq_len": 200,
"emb_dim": 96,
"encoder": "cnn",
"filters": 128,
"rnn_units": 64,
"dense_units": 64,
"dropout": 0.4,
"lr": 0.002,
"seed": 42
},
"fit": {
"epochs": 4,
"batch_size": 256,
"patience": 1
},
"cv": {
"k": 5,
"seed": 42,
"folds": [
{
"accuracy": 0.9125,
"precision": 0.9132852419597235,
"recall": 0.91155,
"f1": 0.9124167959561583,
"macro_f1": 0.9124999210311787,
"roc_auc": 0.97086402125,
"seconds": 173.42162570002256,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.913075,
"precision": 0.9122299286462752,
"recall": 0.9141,
"f1": 0.9131640068929348,
"macro_f1": 0.913074908674326,
"roc_auc": 0.9708592100000001,
"seconds": 171.52324439998483,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.910025,
"precision": 0.9018474053021022,
"recall": 0.9202,
"f1": 0.9109312742841587,
"macro_f1": 0.9100156838675106,
"roc_auc": 0.9693099550000001,
"seconds": 174.84280709997984,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.91055,
"precision": 0.933252427184466,
"recall": 0.88435,
"f1": 0.9081433559252413,
"macro_f1": 0.9104885557642188,
"roc_auc": 0.970956505,
"seconds": 288.10437699995236,
"n_train": 160000,
"n_val": 40000
},
{
"accuracy": 0.9119,
"precision": 0.9043388632570923,
"recall": 0.92125,
"f1": 0.9127161044236389,
"macro_f1": 0.9118922974043698,
"roc_auc": 0.9717235374999998,
"seconds": 275.6892496999935,
"n_train": 160000,
"n_val": 40000
}
],
"summary": {
"accuracy": {
"mean": 0.9116099999999999,
"sd": 0.001290179251112035
},
"precision": {
"mean": 0.9129907732699319,
"sd": 0.012351421094753599
},
"recall": {
"mean": 0.91029,
"sd": 0.015060851569549465
},
"f1": {
"mean": 0.9114743074964263,
"sd": 0.0020417854683419394
},
"macro_f1": {
"mean": 0.9115942733483207,
"sd": 0.0013053594482728683
},
"roc_auc": {
"mean": 0.97074264575,
"sd": 0.0008787500249704196
},
"seconds": {
"mean": 216.7162607799866,
"sd": 59.67473677972244
}
}
},
"cv_seconds": 1083.6313545000157,
"fit_seconds": 1573.5733835999854,
"history": {
"accuracy": [
0.908715546131134,
0.934874415397644,
0.9450677633285522
],
"auc": [
0.9689652323722839,
0.9817413687705994,
0.9860914945602417
],
"loss": [
0.22511020302772522,
0.17026671767234802,
0.14685384929180145
],
"val_accuracy": [
0.9310600161552429,
0.9336199760437012,
0.933430016040802
],
"val_auc": [
0.9798209071159363,
0.980864405632019,
0.9805585741996765
],
"val_loss": [
0.18116672337055206,
0.17459361255168915,
0.1780567616224289
],
"seconds": [
1551.7203770999913
]
},
"params": 2995073,
"predict_seconds": 33.437053100031335,
"test": {
"metrics": {
"accuracy": 0.93424,
"precision": 0.9308834181724367,
"recall": 0.938135,
"f1": 0.9344951414241529,
"macro_f1": 0.9342390023382605,
"roc_auc": 0.9814710290749998
},
"classification_report": {
"negative": {
"precision": 0.937649287953155,
"recall": 0.930345,
"f1-score": 0.933982863252368,
"support": 200000.0
},
"positive": {
"precision": 0.9308834181724367,
"recall": 0.938135,
"f1-score": 0.9344951414241529,
"support": 200000.0
},
"accuracy": 0.93424,
"macro avg": {
"precision": 0.9342663530627959,
"recall": 0.93424,
"f1-score": 0.9342390023382605,
"support": 400000.0
},
"weighted avg": {
"precision": 0.9342663530627958,
"recall": 0.93424,
"f1-score": 0.9342390023382605,
"support": 400000.0
}
},
"classification_report_text": " precision recall f1-score support\n\n negative 0.9376 0.9303 0.9340 200000\n positive 0.9309 0.9381 0.9345 200000\n\n accuracy 0.9342 400000\n macro avg 0.9343 0.9342 0.9342 400000\nweighted avg 0.9343 0.9342 0.9342 400000\n",
"confusion_matrix": [
[
186069,
13931
],
[
12373,
187627
]
]
}
}
}
}12345{
"n_texts": 2000,
"tfidf_portable_max_abs_diff": 2.467379082160548e-07,
"dnn_weights_max_abs_diff": 0.0
}123456789101112{
"vocab_size": 30000,
"seq_len": 200,
"emb_dim": 96,
"encoder": "cnn",
"filters": 128,
"rnn_units": 64,
"dense_units": 64,
"dropout": 0.4,
"lr": 0.002,
"seed": 42
}123version https://git-lfs.github.com/spec/v1oid sha256:dcfb2eb4c1ebe60661201809289b7474e5a7a9be18843a77b5f4a32ff7eb6cb3size 359821601234567891011121314151617181920212223242526{
"token_pattern": "(?u)\\b\\w+\\b|[!?]",
"ngram_range": [
1,
2
],
"lowercase": true,
"sublinear_tf": true,
"norm": "l2",
"labels": {
"0": "negative",
"1": "positive"
},
"params": {
"max_features": 500000,
"ngram_range": [
1,
2
],
"min_df": 3,
"max_df": 0.95,
"C": 4.0,
"max_iter": 1000,
"seed": 42
}
}123version https://git-lfs.github.com/spec/v1oid sha256:06ddb6431bdbac6894c3f9224b987391929e27da767f3e7d17a692ca1531d567size 2612788README.mdAdded+16
classifiers.jsonAdded+506
export_check.jsonAdded+5
review_dnn/config.jsonAdded+12
review_dnn/model.weights.h5Added+3
review_dnn/vocab.jsonAdded
tfidf_portable/tfidf_logreg_config.jsonAdded+26
tfidf_portable/tfidf_logreg_weights.npzAdded+3
tfidf_portable/tfidf_terms.jsonAdded