Fake News Tool (Bonus)
Congratulations on making it this far. You are playing a crucial role in the ongoing battle against fake news!
Since you have demonstrated such bravery, you now have the opportunity to test your own text and evaluate it using the models you have just trained. Simply run the script below and follow the instructions to input your text. Enjoy!
Please note that we will need to apply the same preprocessing steps to your text that we used on our dataset!
Tehtävä
Swipe to start coding
Simply run the provided script.
-
0
means fake news; -
1
means true news.
Ratkaisu
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
news = str(input())
# Creating a DataFrame with the text
df = pd.DataFrame([news], columns=['text'])
# Removing punctuation
df['text'] = df['text'].str.replace('[^\w\s]', '', regex=True)
#Vectorizing the text
text = vectorization.transform(df['text'])
# Making predictions
print('Logistic Regression prediction: ' + str(lr.predict(text)))
print('Decision tree prediction: ' + str(dt.predict(text)))
Mark tasks as Completed
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 7
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme