Category Archives: Python

pprint : Data pretty printer in Python

This article is about a pretty useful built-in module in Python, pprint. The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a well-formatted and more readable way! Let us consider an example: The above code is for getting the geocode information of a place using Google Maps API in JSON format.… Read More »

eval in Python

This article discusses a built-in function in Python, eval. It is an interesting hack/utility in Python which lets a Python program run Python code within itself. The eval() method parses the expression passed to it and runs python expression(code) within the program. The syntax of eval is: eval(expression, globals=None, locals=None) expression: this string is parsed… Read More »

Linear Regression (Python Implementation)

This article discusses the basics of linear regression and its implementation in Python programming language. Linear regression is a statistical approach for modelling relationship between a dependent variable with a given set of independent variables. Note: In this article, we refer dependent variables as response and independent variables as features for simplicity. In order to… Read More »

Short Circuiting Techniques in Python

By short circuiting we mean the stoppage of execution of boolean operation if the truth value of expression has been determined already. The evaluation of expression takes place from left to right. In python, short circuiting is supported by various boolean operators and functions. Short Circuiting in Boolean Operators The chart given below gives an… Read More »

Amazing hacks of Python

Python is indeed one of the smart and most trending language. Here are some cool hacks that makes a python superb among all other languages. List comprehensions: List comprehension is best and efficient technique to get rid of writing unnecessary lines of code. Read Article to know more. Printing a list: List are not printed… Read More »

Naive Bayes Classifiers

This article discusses the theory behind the Naive Bayes classifiers and their implementation. Naive Bayes classifiers are a collection of classification algorithms based on Bayes’ Theorem. It is not a single algorithm but a family of algorithms where all of them share a common principle, i.e. every pair of features being classified is independent of… Read More »

Learning Model Building in Scikit-learn : A Python Machine Learning Library

Pre-requisite: Getting started with machine learning scikit-learn is an open source Python library that implements a range of machine learning, pre-processing, cross-validation and visualization algorithms using a unified interface. Important features of scikit-learn: Simple and efficient tools for data mining and data analysis. It features various classification, regression and clustering algorithms including support vector machines,… Read More »

NumPy in Python | Set 2 (Advanced)

NumPy in Python | Set 1 (Introduction) This article discusses some more and a bit advanced methods available in NumPy. Stacking: Several arrays can be stacked together along different axes. np.vstack: To stack arrays along vertical axis. np.hstack: To stack arrays along horizontal axis. np.column_stack: To stack 1-D arrays as columns into 2-D arrays. np.concatenate:… Read More »

File Objects in Python

A file object allows us to use, access and manipulate all the user accessible files. One can read and write any such files. When a file operation fails for an I/O-related reason, the exception IOError is raised. This includes situations where the operation is not defined for some reason, like seek() on a tty device… Read More »

NumPy in Python | Set 1 (Introduction)

This article will help you get acquainted with the widely used array-processing library in Python, NumPy. What is NumPy? NumPy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python. It contains various features including these… Read More »