HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Non-linear Data structures: Map, Set, Priority Queues > problem:


50517 - Confusion Matrix

Guest
• Review clarifications (1)

Section problems

• 50386 - Conformity
• 50796 - KNN
• 50795 - Trunk
• 50985 - Books Waiting
• 50995 - Group Average
• 50983 - Course Selection
• 50517 - Confusion Matrix
• 50789 - Number of Cities
• 50993 - Products in store
• 50987 - Very Looong Queue
• 50869 - Birthday Celebration
• 50981 - Top popular m-students
• 50794 - Writing Files Into HDD
• 51000 - Book Index
• 51024 - Total Stock Price

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Confusion Matrix

In artificial intelligence, especially in supervised learning, performance of an algorithm is measured using a specific table layout which is called Confusion matrix. On the rows of the table actual object classes are listed. And on the columns the predicted object classes are listed. For example the table below lists confusion matrix for positive and negative objects.

The table on the right tells that there are actually 8 positive and 6 negative objects. The algorithm has predicted 5 positives and 4 negatives correctly. But it has predicted 3 positives as negative and 2 negatives as positive.

Question: Write a program that is going to read actual and predicted classes of n objects. Then your program will show the confusion matrix.

Input specification
You will be given two integers in the beginning: the number of classes (k) and the number of queries (n). Then in the following k lines, you will be k strings (which are in alphabetical order): the object classes where each class label can have at most 20 chars (only 26 English letters). The in the following n lines you will be given two strings.

  • Actual object class
  • Detected class
where 1 ≤ n ≤ 5,000 and 1 ≤ k ≤ 60.

Output specification
Show k-by-k matrix.

Sample Input I
3 10
Apple
Orange
Pear
Pear Pear
Orange Orange
Apple Orange
Orange Orange
Pear Pear
Pear Pear
Orange Pear
Apple Apple
Orange Orange
Apple Pear
Sample Output I
1 1 1
0 3 1
0 0 3


Для отправки решений необходимо выполнить вход.

www.contester.ru