rohit
Comments
Reactions

Fun with none

By : rohit

(If you are in a hurry, here is the fun part.;) A few days ago, I was working with a nullable field, which wasn't behaving as I expected. So I started a shell, and see how nulls compare.

In [1]: None
In [2]: None > 10
Out[2]: False
In [3]: None < 10
Out[3]: True
In [4]: None == None
Out[4]: True
Funny, not as I expected. (Why is None < 10 True. I thought it would be either False or None or cause an Error?) So python is obviously broken, next steps, see the same thing in some other ...

more info..
shabda
Comments
Reactions

Generating pseudo random text with Markov chains using Python

By : Shabda Raaj

First the definition from Wolfram

A Markov chain is collection of random variables {X_t} (where the index t runs through 0, 1, ...) having the property that, given the present, the future is conditionally independent of the past.

Wikipedia is a little clearer

...Markov chain is a stochastic process with markov property ... [Which means] state changes are probabilistic, and future state depend on current state only.

Markov chains have various uses, but now let's see how it can be used to generate gibberish, which might look legit.

The algorithm is,

  1. Have a text which will serve as the corpus from ...

more info..
Topics : seo algorithms
lakshman
Comments
Reactions

Finding keywords using Python

By : lakshman

Update: keywords2.txt is Pride and Prejudice from Project Gutenberg. Attached for convenience.


Finding keywords in a given snippet of text has many uses. From classifying web pages to fighting spam mails, keyword recognition is the first step in many algorithms.

We here show the naive Bayesian filter to find keywords, which was popularised by Paul Graham to discover spam mails.

Steps to find keywords.

  1. Have a large corpus of text against which we will compare.
  2. Find the relative frequency of words in corpus. Eg if your corpus is "the green way is very green way green". Relative frequency is ...

more info..
Topics : algorithms
shabda
Comments
Reactions

Constraint programming in Python

By : Shabda Raaj

Imagine this, you want to solve a problem, the algorithm for which you do not know. You just know the problem.

From wikipedia,
Constraints differ from the common primitives of imperative programming languages in that they do not specify a step or sequence of steps to execute, but rather the properties of a solution to be found.

Assume that there exists an alternate world where you only need to specify the problem, the computer will find out an algorithm to find it, even better if could you write it in Python.

Stop assuming it hapens every day, and this is ...

more info..
Topics : algorithms
© Agiliq, 2009-2012