Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Usually every programmer will start with "Hello World!", but for a change lets start with numbers. I personally believe that numbers play vital role than alphabets.

Numbers
For someone who worked on other programming languages, it will be surprise and shock, since python doesn't have a concept called Variable Declaration.

For new beginners, Variable declaration is a technical way of saying the data type for a variable. Let's go with an example.

In Python 2.x,
In Python 3.x,
If you look at both the examples, there is a very minor change. Let's not worry about it now. If you see the variable 'x', we didn't define what kind of value it is going to hold.

We assigned the value of x to 1, we are printing it, and we are also printing the (data) type of x. In the last line we are printing both the type and value of x. The output will be like this:

Output of Numbers
If you look at the output, python understood that the variable 'x' is of type 'int', even though we didn't declare the variable with the data type 'int'. There is no semicolon at the end of the lines (some language tend to have that semicolon at the end of each line).

Another observation from 2.x and 3.x is the open and close brackets. Python 3 has more explicit way of passing the variables, where as Python 2 doesn't have this. This is one among the different between 2 and 3. Here after all my codes will be Python 3, as I mentioned earlier in the post.
Open your python terminal. If you didn't install Python, check my old posts. In order to open python, press Windows Key and type "Python" and hit Enter.

Launching Python 3.7 Terminal
It will open Python Terminal. This is just to make sure that you have Python Installed on your computer, we will see other programs with Microsoft Visual Studio.

Once the Python terminal is opened (it will look similar to the command prompt with black and white screen). Three greater than symbol (>>>) will be shown. You can try some in built commands like help(), copyright() and other commands.

Once you type any of those commands, it will take you to that particular topic. Let's say I want to read what print command does, so First I type help(), and then print.
Python Terminal - Help
In order to get out of the help menu, need to press Ctrl + C. That will take back you to the original menu (with >>>).

We have something else called IDLE (Python). IDLE is an python's default IDE with lot of options rather than plain command prompt.

Python 3.7.2 IDLE

We can create files, open existing files, save it, save as, print, debug and much more. You can play around with it, let me know your feedback in the comments.
Well, I don't think you need any extra prerequisite other than understanding simple English and a computer with you (preferably with internet connection) to access the source codes and you can move from there.

Python Pre-requisite for Machine Learning
When I started Learning, I started with python, but I realized its so boring since I already know other languages and it doesn't need any challenges in creating the Python scripts. I also got into the puzzle of Python 2 vs Python 3. I started with Python 2 (yes old golden days, where we don't have conflict to choose version), I left it in half and I continued Python 3 in later 2018 for fixing a not working script written in python.

I finally ported those codes to C#, and created "exe" for running on Windows Machines. I don't want to create an environment with every customer to have python installed. But there is a way, where you can convert your Python codes to Windows executable. There are couple of options, Py2exe and PyInstall . Both of them are easy to do, but I personally don't recommend creating executable from python, well that's my personal preference.

Am planning to cover some of python programs in order to complete our machine learning with more clarity. You don't need to know much but at least this. Most of the scripts I have taken and modified it from Stanford University Lectures for CS228 and CS231n. 
With Windows computer, you can still choose other famous IDE's. The first one I recommend is Anaconda. It has Spyder, Jupyter and Many more. I personally recommend using Jupyter notebook for interactive programming.

Anaconda Distribution for R, Python, Jupyter, Spider, NumPy, SciPy, TensorFlow, pandas

Pycharm is another IDE which I used earlier, this is good for Python.

PyCharm - Python IDE for Professional Developers
Jupyter supports other programming languages including R, Scala and almost 40 languages.

In fact all of them are available for free. Some paid versions also there, for personal use we can stick to the free version.

When it comes to Python Language, you don't need to know any other languages to start with. It's super easy and user friendly. Python is built on top of C, and C++.

Python eliminates the variable declaration part. We can see more about python programming in my next post.


There are two different versions of python. One is the older version 2.x and there is new forked version 3.x. The only problem is 3.0 doesn't have backward compatibility, which means the program written for 2.x cannot be run on 3.x and vice versa.

Python 2.x vs Python 3.x

Till today, there are certain group of people who are stick to 2.x version and some of them using 3.x version. There are only minor changes, most of the packages (libraries or 3rd party supporting scripts) supports both the version.

There is no hard and fast rule for version, you can choose whatever you want. In my humble opinion you can choose 3.x if you never used python, because the old version (2.x) is officially discontinued from 2010, no major releases after 2.7.

For Linux users, Python 2.x versions are installed by default, if you have any Linux based OS released after 2010, likely you will have 3.0 but anytime you can install 3.x.

Since Microsoft Visual Studio Code and Visual Studio 2019 both of them are available for free, you can choose whatever you are comfortable with.

Visual Studio Code doesn't have any inbuilt compilers (you need to install different compilers if you want to run any of the other language), on the other hand Visual Studio 2019 comes with compilers for bunch of languages (C, C++, C#, and many more based on selection). When you get something extra, always you need to have more storage.

Visual Studio Code is a light weight editor, and takes very less space for doing our Machine Learning with Python.

Go to the URL: https://visualstudio.microsoft.com/downloads/

Download and install the most comfortable (for you) software. Community Edition is free and comes with lot of perks including online access. You can register for Microsoft account.

MS Visual Studio Code vs MS Visual Studio 2019

Installation process is so easy, just press next wherever you see that option, when it provides check box for selecting environment select python for Visual Studio 2019. Visual Studio Code leave everything in the default state. We are not playing with configurations now.

If you want to download on different machine and install it on different machine, you need to follow a different process.

Once you download the Visual Studio Installer, (vs_community.exe), you need to run it with command prompt. Do not download anything you don't need it, because the entire package is almost 30 GB.

vs_community.exe --layout c:\vslayout --lang en-US

Add anything you want to be added as parameters, for example the below parameters lets you to install C++.

--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended

I have added .NET desktop development and Python.

Python Development in Visual Studio

Select whatever you want along with this, if you have already installed VS you can just go to the Installer, hit of More -> Modify and select this option to install.

Artificial Intelligence is one of the domains which is going to rule the IT field for at least some decades from now on, it could be in various forms Machine Learning, Deep Learning or whatever.

Artificial Intelligence vs Machine Learning vs Deep Learning

Machine Learning

Recently started taking various courses related to machine learning, most of them explains in a very complicated way or at least complicated to me to understand whatever they are trying to convey.

I found lot of free courses and paid courses for the same. Finally I understood what they tried to explain. Let me try to put it in a simple way.

This is my scribbles based on my understanding, it may not be true!

Before learning about I think it is always good to learn the basics about mathematics (yes, the same maths :( ), refresh the hands-on over python (Not the snake, its the programming language) along with various packages (or libraries or tools or whatever) like Numpy, Scipy, Pandas, Scikit-learn, matplotlib, pillow and others as required.

I saw lot of people uses different set of tools, languages, for their tasks. I tried using C, C++ , Matlab (yes you can perform machine in almost any language you are comfortable with) but I felt easy with the following options.

1. Windows 10 OS [was Available for free, you can even use Windows 7]
2. Microsoft Visual Studio 2019 (Yes, its working with 2017 as well) [Community Edition is free] [Alternatively you can use Visual Code as well]
3. Python and its packages [Easy to write code (very less numbers), good for beginners and its free]