Fake News Detector
An app developed with React.js & Python for identifying fake news. It uses article text & keywords to predict the authenticity of news via Logistic Regression model.
Category:
Sub-category:
Natural Language Processing (NLP)
Classification
Overview:
This App uses React.js for frontend and python backend for machine learning. This app uses article headlines, links for the news article and the article itself or the keywords of the article. Then the ML backend then processes the text information and uses the Logistic Regression ML model for prediction.
Description:
The code starts by importing the required modules, including express for creating the web application and child_process for spawning a child process to execute the Python ML backend. It sets up the necessary configurations for the express application, such as JSON parsing, URL-encoded form handling, serving static files, and using the EJS templating engine.
The application defines a route for the homepage ('/'), which renders the index view.
There is also a route for handling the POST request from the form submission ('/check-news'). It extracts the article text, website source, and keywords from the request body. Then, it spawns a child process to execute the Python ML backend script. The article text, website source, and keywords are passed as command-line arguments to the Python script.
The Node.js code listens on port 5000 for incoming requests and logs a message when the server starts.
The ML backend code is written in Python. It imports necessary libraries such as ‘joblib’ and sklearn. The script receives command-line arguments, which are the article text, website source, and keywords.
The ML backend code loads a pre-trained vectorizer and Logistic Regression model from saved files. It vectorizes the preprocessed text using the vectorizer and predicts the class probabilities using the Logistic Regression model. The output class is mapped to human-readable labels ('True Article' or 'Fake Article').
The ML backend code prints the predicted output and the probability of the article being true. However, it doesn't return the result directly but communicates with the Node.js application through stdout.
Programming Language:
React.js (JavaScript), Python
Library:
Express, child_process,’ joblib’, sklearn