Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis

This is a small machine learning project I built to explore how computers can understand the emotion behind a sentence. The idea is simple: you give the program a piece of text, and it tells you whether the feeling behind it is positive or negative.

I wrote it in Python using scikit-learn, and kept the code clean and easy to follow so anyone reading it can understand what is happening at each step.

What this project does

The program reads a small collection of example sentences that are already labeled as positive or negative. It learns from these examples, then uses what it learned to guess the mood of any new sentence you give it.

For example, if you type something like "I really enjoyed this", the program will recognize it as positive. If you type "this was a waste of time", it will recognize it as negative.

How it works

The project goes through a few clear stages.

First, the text is cleaned and turned into numbers using a method called TF-IDF. Computers cannot read words directly, so we need to represent each sentence as a set of numbers that describe which words matter most.

After that, a Logistic Regression model is trained on these numbers. This is a well-known algorithm in machine learning that works nicely for text classification problems like this one.

Once training is done, the program evaluates how accurate the model is, then saves it to a file so you can reuse it later without training again. At the end, it tests the model on a few new sentences to show it in action.

Technologies used

The project is written in Python and uses three main libraries: scikit-learn for the machine learning part, pandas for handling the data, and joblib for saving and loading the trained model.

How to run it

First, clone the repository to your computer:

git clone https://github.com/reemmahdi/sentiment-analysis.git
cd sentiment-analysis

Then install the required libraries:

pip install -r requirements.txt

And finally run the program:

python sentiment_analyzer.py

You should see the accuracy of the model along with the predictions for a few test sentences.

Ideas for future work

The current dataset is small and only for demonstration. There are many ways this project can grow. Using a larger and more realistic dataset such as movie reviews would give better accuracy. Adding support for Arabic text is something I am personally interested in, since most available sentiment datasets are in English. A simple web interface using Streamlit or Flask would also make the project more interactive, and trying more advanced models like LSTM or BERT is a natural next step.

About me

My name is Reem Mahdi. I am a computer engineering student at the University of Mosul with a genuine interest in artificial intelligence and cybersecurity. I enjoy building small practical projects like this one because they help me connect the theory I study with something real I can see and use.

You can find more of my work on my GitHub profile: https://github.com/reemmahdi

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages