the classifier we will be using the labeled data from the scikit-learn package following is the python code to build gender finderlet us import the necessary packagesimport random from nltk import naivebayesclassifier from nltk classify import accuracy as nltk_accuracy from nltk corpus import names now we need to extract the last letters from the input word these letters will act as featuresdef extract_features(wordn= )last_n_letters word[- :return {'feature'last_n_letters lower()if __name__=='__main__'create the training data using labeled names (male as well as femaleavailable in nltkmale_list [(name'male'for name in names words('male txt')female_list [(name'female'for name in names words('female txt')data (male_list female_listrandom seed( random shuffle(datanowtest data will be created as followsnamesinput ['rajesh''gaurav''swati''shubha'define the number of samples used for train and test with the following code train_sample int( len(data)nowwe need to iterate through different lengths so that the accuracy can be comparedfor in range( )print('\nnumber of end letters:'ifeatures [(extract_features(ni)genderfor (ngenderin data