<jupyter_start><jupyter_text>**Challenge:** Calculate the following for the test dataset: The number of documents classified correctly. The number of documents classified incorrectly. The accuracy of the model.<jupyter_code>nr_correct = (y_test == classifier.predict(X_test)).sum()
print(f'{nr_correct} documents classfied correctly')
nr_incorrect = y_test.size - nr_correct
print(f'Number of documents incorrectly classified is {nr_incorrect}')
fraction_wrong = nr_incorrect / (nr_correct + nr_incorrect)
print(f'The (testing) accuracy of the model is {1-fraction_wrong:.2%}')
classifier.score(X_test, y_test)<jupyter_output><empty_output><jupyter_text>**Challenge:** For the testing dataset calculate the recall, precision and f1 score. Google for the scikit learn documentation on this topic to work it out.<jupyter_code>recall_score(y_test, classifier.predict(X_test))
precision_score(y_test, classifier.predict(X_test))
f1_score(y_test, classifier.predict(X_test))
example = ['get viagra for free now!', 
          'need a mortgage? Reply to arrange a call with a specialist and get a quote', 
          'Could you please help me with the project for tomorrow?', 
          'Hello Jonathan, how about a game of golf tomorrow?', 
          'Ski jumping is a winter sport in which competitors aim to achieve the longest jump after descending from a specially designed ramp on their skis. Along with jump length, competitor\'s style and other factors affect the final score. Ski jumping was first contested in Norway in the late 19th century, and later spread through Europe and North America in the early 20th century. Along with cross-country skiing, it constitutes the traditional group of Nordic skiing disciplines.'
          ]
doc_term_matrix = vectorizer.transform(example)
classifier.predict(doc_term_matrix)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07521645021645022, 'fraction_numerical': 0.004329004329004329, 'mean_word_length': 5.353951890034364, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '480048', 'license': 'MIT', 'n_tokens_mistral': 528, 'n_tokens_neox': 493, 'n_words': 203, 'path': 'Project 1/udemy/original7.ipynb', 'repo_name': 'aksan29/machine_learning', 'size': '1848'}