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.1.tar.gz (3.0 kB view hashes)

Uploaded Source

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