background preloader

Learn

Facebook Twitter

How to Tango with Django. A Programmer's Guide to Data Mining. Matrix Programming. Learn Python!!!!!! Learn Python The Hard Way. Understanding the FFT Algorithm. The Fast Fourier Transform (FFT) is one of the most important algorithms in signal processing and data analysis.

Understanding the FFT Algorithm

I've used it for years, but having no formal computer science background, It occurred to me this week that I've never thought to ask how the FFT computes the discrete Fourier transform so quickly. I dusted off an old algorithms book and looked into it, and enjoyed reading about the deceptively simple computational trick that JW Cooley and John Tukey outlined in their classic 1965 paper introducing the subject. The goal of this post is to dive into the Cooley-Tukey FFT algorithm, explaining the symmetries that lead to it, and to show some straightforward Python implementations putting the theory into practice. My hope is that this exploration will give data scientists like myself a more complete picture of what's going on in the background of the algorithms we use. The Discrete Fourier Transform¶ Computing the Discrete Fourier Transform¶ \vec{X} = M \cdot \vec{x} Linux System Mining with Python. In this article, we will explore the Python programming language as a tool to retrieve various information about a system running Linux.

Linux System Mining with Python

Let’s get started. Which Python? When I refer to Python, I am referring to CPython 2 (2.7 to be exact). DRY Principles (Decorators) Python decorators are a powerful tool to remove redundancy.

DRY Principles (Decorators)

Along with modularizing functionality into appropriate bite-sized methods, it makes even the most complex workflows into concise functionality. For example, let's look at the Django web framework, which handles requests by methods which receive a method object and return a response object: def handle_request(request): return HttpResponse("Hello, World") A case I ran into recently was having to write several api methods which must: return json responsessome must return an error code if it's a GET request vs a POST As an example, for a register api endpoint, I would write something like this: However, I'm going to need json responses and error returned in pretty much every api method I create. Django Best Practices. Show Navigation Navigation If you are looking to make the jump from beginner to pro, or just trying to sharpen your skills, you'll find Django Best Practices chock full of knowledge.

Django Best Practices

Will it Python. Slender Means I'd like to drop my trousers to the world.

Will it Python

I am a man of means, of slender means. Better Python APIs. Python comes with a large number of built-in functions, operators and keywords.

Better Python APIs

They make working with data structures and built-in types very easy, but usually when we define our own data types (classes) we also tend to come up with our own ways to manipulate and consume our data. One of the nice things in python, is that we don't have to. Python threads synchronization: Locks, RLocks, Semaphores, Conditions, Events and Queues. This article describes the Python threading synchronization mechanisms in details.

Python threads synchronization: Locks, RLocks, Semaphores, Conditions, Events and Queues

We are going to study the following types: Lock, RLock, Semaphore, Condition, Event and Queue. Also, we are going to look at the Python internals behind those mechanisms. The source code of the programs below can be found at github.com/laurentluce/python-tutorials under threads/. First, let’s look at a simple program using the threading module with no synchronization. Python Types and Objects.

Python Attributes and Methods. Fast Non-Standard Data Structures for Python. Python provides great built-in types like dict, list, tuple and set; there are also array, collections, heapq modules in the standard library; this article is an overview of external lesser known packages with fast C/C++ based data structures usable from Python.

Fast Non-Standard Data Structures for Python

Note Disclaimer: I created datrie, marisa-trie, hat-trie and DAWG Python wrappers. What is a metaclass in Python. Pickle. The pickle module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python object structure.

Pickle

“Pickling” is the process whereby a Python object hierarchy is converted into a byte stream, and “unpickling” is the inverse operation, whereby a byte stream is converted back into an object hierarchy. Pickling (and unpickling) is alternatively known as “serialization”, “marshalling,” or “flattening”, however, to avoid confusion, the terms used here are “pickling” and “unpickling”. This documentation describes both the pickle module and the cPickle module. The Flask Mega-Tutorial. This is the first article in a series where I will be documenting my experience writing web applications in Python using the Flask microframework.

The Flask Mega-Tutorial

NOTE: This article was revised in September 2014 to be in sync with current versions of Python and Flask. Here is an index of all the articles in the series that have been published to date: My background I'm a software engineer with double digit years of experience developing complex applications in several languages. Flask and MongoEngine. Introduction This tutorial describes the process for creating a basic tumblelog application using the popular Flask Python web-framework in conjunction with the MongoDB database.

Python Scientific Lecture Notes. Python4Astronomers. A naive simulator of gravity, written in Python. (Coded during a 2010 summer night... updated with Runge-Kutta solver during Xmas 2012 weekend... Reddit-ed) I've always been fascinated by space - ever since I read "The Family of the Sun", when I was young. And I always wanted to simulate what I've read about Newton's law of gravity, and see what happens in... a universe of my own making... :‑) So eventually, I sat down and did it. The following code "sprays" planets randomly, inside a 900x600 window (the values are in the code, change them at will).

Gravity, inversely proportional to the square of the distance, and linearly proportional to the product of the two masses Elastic "mergings" of two planets if they are close enough to touch: a merged planet is then created, that maintains the momentum (mass times velocity) and the mass of the two merged ones. Self. Think Bayes - Bayesian Statistics Made Simple (PDF) PyML - machine learning in Python. Basic Sentiment Analysis with Python. 01 nov 2012 [Update]: you can check out the code on Github. Collections. New in version 2.4. Source code: Lib/collections.py and Lib/_abcoll.py. MapReduce. MapReduce is a programming model for processing large amounts of data in a parallel and distributed fashion. It is useful for large, long-running jobs that cannot be handled within the scope of a single request, tasks like: Analyzing application logsAggregating related data from external sourcesTransforming data from one format to anotherExporting data for external analysis With the App Engine MapReduce library, your code can run efficiently and scale automatically.

App Engine takes care of the details of partitioning the input data, scheduling execution across a set of machines, handling failures, and reading/writing to the Google Cloud platform. Overview App Engine MapReduce is an open-source library that is built on top of App Engine services, including Datastore and Task Queues. There are no usage charges associated with the MapReduce library. Stages. MapReduce with MongoDB and Python. Recommending friends with MapReduce and Python. Hi all, In this post I will present one of the tecnhiques used at Atépassar, a brazilian social network that help students around Brazil in order to pass the exams for a civil job, our recommender system.