<jupyter_start><jupyter_text>IBM Quantum Challenge Fall 2021 Challenge 3c Hint How to convert three label probabilities into 3-class predictionIn Challenge 3c, you need to create a final 3-class classification prediction from three label probabilities. Here is a hint for that part. The following is an example of what you should implement for 5 samples.**Input**: three label probalibities- label 0: [0.1, 0.5, 0.2, 0.9, 0.4]- label 2: [0.3, 0.1, 0.1, 0.3, 0.6]- label 3: [0.6, 0.2, 0.4, 0.1, 0.3]**Output**: 3-class classification prediction- prediction: [3, 0, 3, 0, 2]The conversion rule is to use the label with the highest label probability as the prediction for each data. For example, looking at the first data, the probalities of label 0, 2, 3 are 0.1, 0.3, 0.6 respectively, where the probability of label 3 is the highest, therefore the prediction is chosen to be label 3.Such conversion rules can be implemented by a great variety of approaches. The Challenge 3 notebook gives a hint of an approach using np.where. In this hint, an additional approach using np.argmax is presented. Here, as in the Challenge 3 notebook, it is demonstrated for just two labels, so you will need to extend it for three labels for submission.First, define the example data shown above.<jupyter_code>import numpy as np

pred_0 = [0.1, 0.5, 0.2, 0.9, 0.4]
pred_2 = [0.3, 0.1, 0.1, 0.3, 0.6]<jupyter_output><empty_output><jupyter_text>Next, stack the data.<jupyter_code>pred_02 = np.vstack([pred_0, pred_2])
pred_02<jupyter_output><empty_output><jupyter_text>Then, apply np.argmax. This allows us to get which label probability is higher. In this case,  the result "0" means label 0 probability is higher while the result "1" means label 2 probability is higher.<jupyter_code>argmax_02 = np.argmax(pred_02, axis=0)
argmax_02<jupyter_output><empty_output><jupyter_text>Finally, convert each value to its corresponding label, and you have "pred_test".<jupyter_code>pred_test_02 = np.where(argmax_02==0, 0, 2)
pred_test_02<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09077526987242394, 'fraction_numerical': 0.0534838076545633, 'mean_word_length': 4.979472140762463, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '427757', 'license': 'Apache-2.0', 'n_tokens_mistral': 702, 'n_tokens_neox': 634, 'n_words': 278, 'path': 'hints/challenge-3-hint.ipynb', 'repo_name': 'HuangJunye/ibm-quantum-challenge-fall-2021', 'size': '2038'}