<jupyter_start><jupyter_text>Prediction with default recipe is good<jupyter_code>print('Confusion matrix - Actual versus prediction with numeric recipe')
cf_num_recipe = pd.crosstab(df['class'],df_predict_numeric.predicted_numeric)
cf_num_recipe<jupyter_output><empty_output><jupyter_text>Versicolor - 30 examples got misclassified as Virginica<jupyter_code>def print_metrics(cf_matrix):
    # Note:AWS ML computes all these for you...demo to show how these are calculated.
    
    # Total samples is sum of all columns in each row
    total_samples = cf_matrix.sum(axis=1).sum()
    # Diagonal contains correct class predictions
    accuracy = np.diag(cf_matrix).sum()/total_samples
    
    print('Accuracy: {0:0.3f}'.format(accuracy))
    print('\n')
    
    # TPR, Recall = True Positive/Actual Positive
    recall = np.diag(cf_matrix)/cf_matrix.sum(axis=1)
    print('recall')
    print(recall)
    print('\n')
    
    # Precision = True Positive/Predicted Positive
    precision = np.diag(cf_matrix)/cf_matrix.sum(axis=0)
    print('precision')
    print(precision)
    print('\n')
    
    f1_scores = 2 * recall * precision/(recall+precision)
    print('f1 scores')
    print(f1_scores)
    print('\n')
    
    print('average f1 score {0:0.3f}'.format(f1_scores.mean()))
    print('\n')    
print_metrics(cf_bin_recipe)
print_metrics(cf_num_recipe)
df_predict_numeric.predicted_numeric.value_counts()
df_predict_default.predicted_default.value_counts()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11646586345381527, 'fraction_numerical': 0.011378848728246318, 'mean_word_length': 4.476190476190476, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '463499', 'license': 'MIT', 'n_tokens_mistral': 520, 'n_tokens_neox': 505, 'n_words': 94, 'path': 'Udemy Course/ProjectSetup/Python/ml_class_iris.ipynb', 'repo_name': 'Kshitij68/AWS_tuts', 'size': '1494'}