Question: Python 3 code. Please. Problem progrannpy plotter py 1 From plotter import plot pnr 2 from hidden_11b 1nport classify_dac 3 from hidden11b 1nport train_classifier 4

Python 3 code. Please.
Problem progrannpy plotter py 1 From plotter import plot pnr 2 from hidden_11b 1nport classify_dac 3 from hidden11b 1nport train_classifier 4 from collections import defaultdict as dd 5 import csv 6 Increase the f1e1d s1 ze 11n1t (we have b1g flues) 7 csw.field s1ze 11n1t(int(le7)) Write the functions cale_prec1 51 on test-set) and calc-recau (test-set) which both take a string test-set which refers to a CSV file with doouments far testing inat included in our training sot), and return a dictionaries of the precision and recall for eachlanguage. We have provided a mini test set snall_test.csv far yau to develop your code aver The format of this file (though it is nat obviaus from laaking at it!) is lang1,texti lang2, text2 We also provide you with an implementation ofclassify-doc (docunent, lang.counts). which takes a string document, and language counts, and retur ns a string representing the possible language of the document. We provide you with a small training set, which is loaded into defautt lang counts for you as per usual. This is adifferent training set to the other problems, made significantly smaller due to !) hle train the class1 fter here 10 default-lang-counts tra! n-class1 fler( , snall-tra1n.csv') = 12 - def calc precision(reST seT): "calc precision takes the filenane of a csv file test set and returns a dictionary of the prec1s1on of the class1fier per Language"" Your coe here pass Remember, for a particular language where Nurei Is the number of documents the classiher got right, and NProdictwd Is the number predicted for that language. Note that you should calculate the precislon for only those languages where classify_doc has predicted one or more of the test documents to be of that language [for languages where there are no predictions, no precision shauld be calculated) For recall: 18, 19 def calc-recall(test-set); calc recall takes the filenane of a csw file testset and returns a d1ct1onary of the recall of the classif1er per language. #Your code here 21 24 # Run th1s to have a look at a plot 25 #1angs: [.Bosn1 an , "Danish,' 'Germsn. , .Asturian*, *Arabic.] 26 set'snall TesT.CSV 27 preclston d = calc prec1s10n(tset) 28 recall-d : calc-recall(tset) 29 plot.pnr (precision_d, recalld, langs) Recall = where N is the number of documents written In that language In the test set Recall should be calculated for all languages represented lin the test set (in terms of the actual labels) Your functions should behave as follows p calc.precn'mall test.csw p'Asturian'1 >>> r catc., recall(' snall-test, csv ') 0.9259259259259259 Submissions Output Autosaved Once you have done that, visualise the precision and recal l of your classifer with plot pnr (precison dict, recall dict, langs) which takes as arguments a dictionary of preclslon per language (precision_dict), adictionary of recall per language (recall dict), and a list of the languages to be plotted (1 angs The function then generates a bar chart Have a look at the code included in 1orter-Py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
