Logo Lanfrica

HafsaZahran1/Hespress-Classification

Domain:

natural language processing

Record type:

project
Creator:
Haf
Host:
This repository contains the implementation of a machine learning-based text classifier for a multi-class text classification task. The goal is to classify news stories into different topics, such as art and culture, economy, faits-divers, marocains-du-monde, medias, politique, regions, societe, sport, and tamazight. # Hespress-Classification This repository contains the implementation of a machine learning-based text classifier for a multi-class text classification task. The goal is to classify news stories into different topics, such as art and culture, economy, faits-divers, marocains-du-monde, medias, politique, regions, societe, sport, and tamazight. ## Dataset This repository contains a Python script for analyzing Moroccan news articles from Hespress using various data analysis techniques. The script provides insights into the class distribution, top frequent n-grams, and lengths of examples in words and letters. Dataset The dataset consists of Moroccan news articles from the Kaggle, collected and saved in CSV format. The 'data' folder within the repository holds the CSV files. The Kaggle dataset link: kaggle.com ## A brief description of the whole training process for the text classification: 1. **Data Loading and Preprocessing:** - Load the news stories dataset from CSV files. - Remove unwanted columns. 2. **Data Splitting:** - Split the dataset into text input (X) and target variable (y). - Use the last 20% of each file as the test set to ensure a diverse distribution of topics in the test data. 3. **Feature Extraction (TF-IDF):** - Convert the text data into numerical features using TF-IDF (Term Frequency-Inverse Document Frequency) vectorization. - Use the TfidfVectorizer from scikit-learn to transform the text data into TF-IDF features. - Limit the number of features to 5000 (can be adjusted based on available resources). 4. **Model Selection and Training:** - Choose a machine learning model suitable for multi-class text classification, such as Multinomial Naive Bayes. - Initialize the selected model. - Train the model using the TF-IDF features (X_train_tfidf) and the corresponding target labels (y_train). 5. **Model Evaluation:** - Make predictions on the test set (X_test_tfidf) using the trained classifier. - Ca …