Saturday, 13 July 2019

Complete Program

Hi All,

Please find the complete Sentimental Analysis program

trainingdata.csv

i am fine,neutral
its great,positive
he is good,positive
so bad,negative
you are waste,negative

testdata.csv

1,raj,i am fine
2,manu,he is great
3,Raji,it is bad

------------------------------------------------------------------------------------------------------------------------



from nltk import NaiveBayesClassifier as nbc
from nltk.tokenize import word_tokenize
from itertools import chain
import csv

with open('trainingdata.csv','r') as csvinput:
    reader=csv.reader(csvinput,delimiter=",")
    rownum = 0 
    training_data = []

    for row in reader:
        training_data.append (row)
        rownum += 1

vocabulary = set(chain(*[word_tokenize(i[0].lower()) for i in training_data]))

feature_set = [({i:(i in word_tokenize(sentence.lower())) for i in vocabulary},tag) for sentence, tag in training_data]

classifier = nbc.train(feature_set)

with open('testdata.csv','r') as csvinput:
    with open('data.csv', 'w') as csvoutput:
        writer = csv.writer(csvoutput, lineterminator='\n')
        reader1 = csv.reader(csvinput)

        all = []
        row = next(reader1)
        

        for row in reader1:
            test_sentence = row[2]
            featurized_test_sentence =  {i:(i in word_tokenize(test_sentence.lower())) for i in vocabulary}
            print ("test_sent:",test_sentence)
            print ("tag:",classifier.classify(featurized_test_sentence))
            row.append(classifier.classify(featurized_test_sentence))
            all.append(row)
        writer.writerows(all)

Friday, 12 July 2019

Dear All,

Find the steps in Twitter Sentimental Analysis using Python

1. Import necessary packages

from nltk import NaiveBayesClassifier as nbc
from nltk.tokenize import word_tokenize
from itertools import chain
import csv


2. Read the input file using csv reader and generate a list of those tweets

3. Generate a vocabulary

vocabulary = set(chain(*[word_tokenize(i[0].lower()) for i in training_data]))


4. Generate training data

feature_set = [({i:(i in word_tokenize(sentence.lower())) for i in vocabulary},tag) for sentence, tag in training_data]

5. Train the classifier

classifier = nbc.train(feature_set)

6. Generate output csv file

writer = csv.writer(csvoutput, lineterminator='\n')

7. Generate Test Input

featurized_test_sentence =  {i:(i in word_tokenize(test_sentence.lower())) for i in vocabulary}

8. Classfiy and create output data

row.append(classifier.classify(featurized_test_sentence))
all.append(row)

9. Flush output data to an output csv file

writer.writerows(all)

Wednesday, 21 November 2018

PIP - How to install PIP in Python

PIP and Python

Hi All,

PIP is a recursive Acronym PIP Installs Packages.
This is used to install Python packages.

We can download the pip.py from internet and run to configure the same.
Once installation is done we can install packages in Python using pip.

Eg

pip install packagename

Wednesday, 18 July 2018

PIR Sensor

Hi All,

Using this PIR sensor we can sense the presence of Human beings.

Use these resources for PIR Sensor.

Video : for Connection

https://www.youtube.com/watch?v=YFjEXt5oBYE
[Search for 'How To Connect PIR Motion Detector Sensor [Arduino Tutorial] ']

Code : for execution

http://playground.arduino.cc/Code/PIRsense



Saturday, 21 April 2018

Simple Python Program

Hi All,

See some simple programs in Python.

#Program 1
# To Add 2 numbers

num1 = 1.2
num2 = 3.3
# Add numbers
result= float(num1) + float(num2)
# Display the result
print('The sum of {0} and {1} is {2}'.format(num1, num2, result))

Saturday, 16 December 2017

Advanced Computer Science Projects 2017 -2018

Hi All,

Doing an innovative project using advance technology is no big deal.
You need passion...that's the only requirement.
Anyone can be taught any technology if interested.


1. Windspeed prediction using Artificial Neural Networks (ANN)

2. Weather Reporting using R-Pi, Python and Twitter Interface

3. Student performance Prediction using Artificial Neural Networks (ANN)

4. Weather Forecasting using Artificial Neural Networks (ANN)

5. Twitter Sentiment Analysis using Python

6. Cancer prediction using Artificial Neural Networks (ANN)

7. Protein Interaction Prediction using Support Vector machine(SVM)

8. Car Number Plate detection and recognition using Matlab Image Processing Toolkit.

9. DNA cryptography for Text and Image Encryption using Matlab

Friday, 15 December 2017

Data cleaning using Python


Hi, All
Data cleaning is considered vital. See the code below.



import HTMLParser
html_parser = HTMLParser.HTMLParser()
tweet = html_parser.unescape(original_tweet)
# Actual text
#“I luv my <3 iphone & you’re awsm apple. DisplayIsAwesome, sooo happppppy 🙂 http://www.apple.com”
tweet = original_tweet.decode("utf8").encode(‘ascii’,’ignore’)
APPOSTOPHES = {“'s" : " is", "'re" : " are", ...} ## Need a huge dictionary

words = tweet.split()

reformed = [APPOSTOPHES[word] if word in APPOSTOPHES else word for word in words]

reformed = " ".join(reformed)
cleaned = “ ”.join(re.findall(‘[A-Z][^A-Z]*’, original_tweet))
    tweet = _slang_loopup(tweet)
tweet = ''.join(''.join(s)[:2] for _, s in itertools.groupby(tweet))


https://www.analyticsvidhya.com/blog/2014/11/text-data-cleaning-steps-python/







Advanced data cleaning:

Grammar checking:
Spelling correction: