HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN - 372 Homework > problem:


2015-10. 50517 - Confusion Matrix

CEN - 372 Homework

Start: Sep.16.2015 at 10:00:00 AM
Finish: May.16.2016 at 02:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 2015-10. 50517 - Confusion Matrix
• 2015-20. 50518 - Histogram Equaliz...
• 2015-30. 50519 - Image Filtering
• 2015-40. 50498 - K-Means
• 2015-50. 50659 - Covariance Matrix
• 2015-60. 50505 - kht Puzzle
• 50. 50796 - KNN

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