Monday, April 10, 2017

Installing texlive in My ubuntu Machine

I want to try translating some computer programming books to malayalam...
texlive -latex full packages will give you an opportunity write good looking books.

installation in Ubuntu:

apt-get install texlive-full

I don't think texlive support malayalam fonts,but let me see whether I can copy-paste from some translator.


Wednesday, March 22, 2017

numPy Python module - Revisit

I know that there is a module called 'numPy' in python  from long time before, but I did not care that one much, thinking it is just library for math functions.

If you try to learn Machine learning, then it is important to learn the numPy module as a prerequisite for ML. The calculation in Machine learning functions are build with matrix or column vector manipulations.

I remember that how difficult is it to do matrix manipulations in C programming. Usually it will come as a lab exam in college :-) ( that skill is needed),but if you are really focusing on applications or functionalities , the calculations part should be minimal and easy. Numpy module gives that freedom to focus on the applications part.


from numPy import *

matrix = array([[1,2,3],[3,4,5]])

the above single statement give you a matrix 2 columns and 3 raws.  how cool it is !!!

you can get the matrix dimension with following python statement

matrix.shape

Matrix addition - looks so simple as shown below






if you check the data type for 'matrix' you will get the below -

>>> type(matrix)
"<"class numpy.ndarray="">

Tuesday, March 21, 2017

5 things I find very useful and new in Python programming

1.  List - (a list of values. Each one of them is numbered, starting from zero )

I find it very handy in Python programming language , because looping through list and reading each values are very easy in List.


num = [3,4,5,6]

items = ['desk','pen','pencil']

you can read through List very easily as below -























2. split function


You can split a string with any seperator and put into a list very easily with this function.











3.Map function


Map applies a function to all the items in an input_list.



Output:

{1,4,9,16]






4. Reduce Function:

Reduce is a really useful function for performing some computation on a list and returning the result.

Below example we are passing the 'sum' function to inbuild 'reduce' function and getting the total sum for the list of numbers.




Output:
14





5.Some thing you find very strange in Python ( Mutable and Immutable objects)

I thought it was bug, but its not ..

eg:
First Lets me create a list as below.

a = [1,2]


then simply create another list 'b' and assign  'a' + [3]

b= a;
b+=[3]

what you will expect on 'b' .. obviously .. [1,2,3]

But what you expect on 'a'... I thought that i didn't change anything in 'a' , so it should be same, but what actually 'print a'  become [1,2,3]

read below link for more details - http://book.pythontips.com/en/latest/mutation.html

https://codehabitude.com/2013/12/24/python-objects-mutable-vs-immutable/