Logo Lanfrica
  • Home
  • Atlas
  • Insights
  • Docs
  • Sign in

© 2026 Lanfrica. All rights reserved. All copyrights of the resources shown on the Lanfrica website belong to the original copyright holders, unless explicitly stated otherwise.

AlfredBaraka/Swahili-News-Classifier

Domain:

natural language processing

Record type:

software
Creator:
Alf
Host:
Text Classification with Naive Bayes This project demonstrates a simple text classification model using Naive Bayes and scikit-learn. The model is designed to classify text data into predefined categories. The dataset is loaded in Parquet format, and the model utilizes a text vectorization technique and Multinomial Naive Bayes for classification. Requirements Python 3.10 + scikit-learn pandas numpy You can install the necessary dependencies using pip: ``` pip install scikit-learn pandas numpy pyarrow ``` Files train.parquet: Training dataset containing the text and labels for training. test.parquet: Test dataset for evaluating the model. habari: Sample input text for classification. Steps Loading Data: The dataset is loaded from Parquet format using ``` pd.read_parquet() ``` The training data (X_train, y_train) and test data (X_test, y_test) are separated. Text Vectorization: A CountVectorizer is used to convert the text data into a numerical representation (bag of words). Alternatively, TfidfVectorizer could be used for better performance on some tasks. Model Creation: A Naive Bayes model (MultinomialNB) is used for classification. A pipeline is created to combine the vectorizer and classifier. Model Training: The model is trained using the fit() method on the training data. Prediction: The trained model is used to predict the labels for the test data. Evaluation: Accuracy of the model is calculated by comparing predicted labels with the true labels from the test data. ``` import numpy as np from sklearn.naive_bayes import MultinomialNB from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer import pandas as pd from sklearn.pipeline import make_pipeline from sklearn.metrics import accuracy_score # Load data that are in parquet format train_data = pd.read_parquet('data/train.parquet') test_data = pd.read_parquet('data/test.parquet') X_train = train_data['text'] y_train = train_data['label'] X_test = test_data['text'] …

Visit

github.com

Languages

Swahili

Similar

Gloriah/swahili-news-classifierMartinKalema/Swahili-News-ClassifierDavisy/Swahili-News-Classifier-APIkatoernest/afro-xlmr-swahili-news-classifierDavisy/Swahili-News-Classifier-Streamlit-AppKona15/yoruba-news-classifier

Gloriah/swahili-news-classifier

MartinKalema/Swahili-News-Classifier

ULMFiT Model that classifies swahili news articles ### Swahili-News-Classifier Swahili is spoken b

Davisy/Swahili-News-Classifier-API

An API developed by using the FastAPI library and uses an NLP model to classify the category of the

katoernest/afro-xlmr-swahili-news-classifier

Davisy/Swahili-News-Classifier-Streamlit-App

A simple Streamlit App to classify swahili news into different categories. # Swahili News Classifie

Kona15/yoruba-news-classifier

# Yoruba Text Classification Model for News Categorization ## Project Overview This project develo