Skip to main content

Machine Learning Utils

Project description

Machine Learning Kit (mlkit)

INSTALL

pip install ml_scripts

EXAMPLES

1. Model Evaluate

1.1 Classifier Evaluate

  • Add Data
from ml_scripts.model_evaluate import ClassifierEvaluate

pred_probs_vectors = [[1, 3, 2, 7, 0],
                      [4, 7, 2, 8, 2],
                      [1, 3, 7, 4, 9]]  # normalization is not required
real_idxes = [2, 1, 3]
ce = ClassifierEvaluate(pred_probs_vectors, real_idxes)

more_pred_probs_vectors = [[7, 5, 3, 6, 1],
                           [1, 4, 6, 7, 9]]
more_real_idxes = [0, 4]
ce.extend_pred_and_real(more_pred_probs_vectors, more_real_idxes)
  • Calculate Topk-Accuracies
ce.get_topk_acc(1)
# 0.4

ce.get_topk_acc(2)  
# 0.6

ce.get_topk_acc(3)  
# 1.0
  • Calculate Topk-Precision/Recall/Accuracies for each class
ce.get_topk_tp_fn_fp_tn_for_idxes(1)
# {0: (1, 0, 0, 4),
#  1: (0, 1, 0, 4),
#  2: (0, 1, 0, 4),
#  3: (0, 1, 2, 2),
#  4: (1, 0, 1, 3)}

ce.get_topk_tp_fn_fp_tn_for_idxes(2)
# {0: (1, 0, 0, 4),
#  1: (1, 0, 1, 3),
#  2: (0, 1, 1, 3),
#  3: (0, 1, 4, 0),
#  4: (1, 0, 1, 3)}
  • Save All Results of Evaluation
ce.save_result(max_k=50, result_dp='[directory_path_to_save_result_of_evaluation]')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml_scripts-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file ml_scripts-0.0.3.tar.gz.

File metadata

  • Download URL: ml_scripts-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.7.13

File hashes

Hashes for ml_scripts-0.0.3.tar.gz
Algorithm Hash digest
SHA256 027b311976a88e801b90a023139d2ee79ea4010f84dea90d4a1e054fc28a9b2a
MD5 daecd7874c0233bc96a42e5e5c06cc5f
BLAKE2b-256 be22538f69a1aee58059998336ef296ce992ca45d6b74b33d08c152b9904e6d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page