Python: Read Write JSON

In this article, I will be showing how to read data from a JSON file and write data to a new JSON file using Python programming language. Suppose, I have the following JSON data which is saved in a file named sample-1.json. Download: sample-1.json {"votes": {"funny": 25, "useful": 59, "cool": 29}, "user_id": "1", "name": "User … Read more

Python: Read Write CSV

In this article, I will be showing how to read data from a CSV file and write data to a new CSV file using Python programming language. Here’s a scenario: Suppose, I have a CSV file with 3 columns (user_id, item_id, and star_rating). It has data of 100 users. Each user has rated 20 different … Read more

Python: Graph plotting with Matplotlib (Bar Chart)

This article deals with plotting line graphs with Matplotlib (a Python’s library). Below is the data which we will use to plot the bar chart. The data is saved in a CSV file named result3-blog.csv. As seen above, the CSV file contains result in terms of F1 measure which is an accuracy measure generally used … Read more

Python: Graph plotting with Matplotlib (Line Graph)

This article deals with plotting line graphs with Matplotlib (a Python’s library). In the article Machine Learning & Sentiment Analysis: Text Classification using Python & NLTK, I had described about evaluating three different classifiers’ accuracy using different feature sets. In this article, I will be using the accuracy result data obtained from that evaluation. Below … Read more

Machine Learning & Sentiment Analysis: Text Classification using Python & NLTK

This article deals with using different feature sets to train three different classifiers [Naive Bayes Classifier, Maximum Entropy (MaxEnt) Classifier, and Support Vector Machine (SVM) Classifier]. Bag of Words, Stopword Filtering and Bigram Collocations methods are used for feature set generation. Text Reviews from Yelp Academic Dataset are used to create training dataset. Cross-validation is … Read more

Python: Print variable in human readable form like print_r in PHP

print_r prints a PHP variable into human readable form. The same can be achieved in Python using pprint module. Here is an example python code: from pprint import pprint student = {'Student1': { 'Age':10, 'Roll':1 }, 'Student2': { 'Age':12, 'Roll':2 }, 'Student3': { 'Age':11, 'Roll':3 }, 'Student4': { 'Age':13, 'Roll':4 }, 'Student5': { 'Age':10, 'Roll':5 … Read more