-
-
Save amankharwal/531d2e91e66df8b426332cf2f8b806e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from sklearn.feature_extraction.text import CountVectorizer | |
from sklearn.model_selection import train_test_split | |
from sklearn.naive_bayes import MultinomialNB | |
data = pd.read_csv("news.csv") | |
x = np.array(data["title"]) | |
y = np.array(data["label"]) | |
cv = CountVectorizer() | |
x = cv.fit_transform(x) | |
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.2, random_state=42) | |
model = MultinomialNB() | |
model.fit(xtrain, ytrain) | |
import streamlit as st | |
st.title("Fake News Detection System") | |
def fakenewsdetection(): | |
user = st.text_area("Enter Any News Headline: ") | |
if len(user) < 1: | |
st.write(" ") | |
else: | |
sample = user | |
data = cv.transform([sample]).toarray() | |
a = model.predict(data) | |
st.title(a) | |
fakenewsdetection() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment