Introduction To Python - agastya2002/IECSE-ML-Winter-2020 GitHub Wiki
Hi there!
Machine learning is one of the hottest fields of research and innovation today! With the help of machine learning and artificial intelligence, advancements in technology and in the industry are taking place at a staggering rate, helping researchers and engineers alike defy what previously seemed impossible.
Hence for those who have zero experience in the maths or programming involved, venturing into and exploring the world of machine learning might seem like an extremely daunting task! But you need not worry as your mentors are here to help you and guide you along the way. The most important element of your success in this Winter Project is purely your own interest and motivation to learn, to complete the tasks and assignments, and to see this winter project through!
Why Python?
If your aim is growing into a successful coder, you need to know a lot of things. But, for Machine Learning & Data Science, it is sufficient enough to master at least one coding language and use it confidently.
Python is a perfect choice for beginners! It is a widely used general-purpose, high-level programming language.
Python allows programming in Object-Oriented and Procedural paradigms. The biggest strength of the Python is large library which can be used for the following
- Machine Learning
- GUI Applications (like Kivy, Tkinter, PyQt etc. )
- Web frameworks like Django (used by YouTube, Instagram, Dropbox)
- Image processing (like OpenCV, Pillow)
- Web scraping (like Scrapy, BeautifulSoup, Selenium)
- Test frameworks
- Multimedia
- Scientific computing
- Text processing and many more..
Getting started
There are two ways to getting started with writing and running your first python command/program statement. You can either use:
- Python Notebooks
- Native Python installation using text editors
1. Python Notebooks
The IPython Notebook is now known as the Jupyter Notebook. It is an interactive computational environment, in which you can combine code execution, rich text, mathematics, plots and rich media.
Colab is Google's flavor of Jupyter Notebooks. They provide a seamless experience for executing python programs and are great for Machine Learning and Artificial Intelligence too because Google also provides users with free access to their GPUs and TPUs for more computationally expensive tasks.
They also have all the python libraries pre-installed, therefore you won't have to be concerned with installing any additional python libraries that we would require.
For a hassle free experience, we recommend using Google Colab: https://colab.research.google.com/notebooks/welcome.ipynb# (Use Google Chrome preferably) The above link provides a short tutorial, introducing you to the interface.
Note: You guys might also come across Jupyter Notebooks - a flavor of python. Those who already have it pre-installed and are comfortable using it may continue doing so. There is no such restriction. Any difficulties you can contact your mentors. Here are the links for installing jupyter notebooks: https://jupyter.org/install
Jupyter Tutorial: https://www.dataquest.io/blog/jupyter-notebook-tutorial/
If you chose to use jupyter notebooks you may skip the rest of the document and continue on to the next page.
2. Installing Python
For the more adventurous of the lot,
-
Windows Users
Visit the link below for detailed instructions: https://realpython.com/installing-python/#windows
Install 3.6 to 3.8. 64-bit version installer.
NOTE
Remember to click ADD TO PATH during installation.
-
Linux Users
Visit the link below for detailed instructions: https://realpython.com/installing-python/#linux
-
MacOS Users
Visit the link below for detailed instructions: https://realpython.com/installing-python/#macos-mac-os-x
Keep in mind that as we progress ahead, we will be requiring libraries that may not be pre-installed on your system. We will be uploading the required steps to install the same. There are also several resources online for installing the required libraries.
Note:
There is a very good chance that python will already be installed on Linux and MacOS. You can check the same using python3 --version
.
We would also be using python3, i.e., python with versions 3.x.y
So please make sure that your are installing python3.
Text Editors
You will require text editors to write your python programs. A few of the popular text editors are:
- Sublime Text (Preferable, light and most popularly used)
- VS Code
- Atom
There are several others out there, and you may use whichever you're comfortable with.
Writing and running your python program in the terminal
- Fire up your text editor and start writing your python program. eg:
# This program prints Hello, world!
print('Hello, world!')
- Save it as filename.py in your preferred directory
- Open the terminal/command prompt inside the directory where you have saved the python file.
- Execute the following command to execute the python file:
> python3 filename.py
- You should get the output on the terminal as:
Hello, World!
Here is a link for any more help required: https://realpython.com/run-python-scripts/
For those who are working with a native python installation, there might be cases that the packages and libraries we have used might not be pre-installed on your system.
You will find that pip
is commonly used across all three operating systems as means to manage python packages and libraries.
Here are links that explain how to install python packages and libraries:
- Windows https://datatofish.com/install-package-python-using-pip/
- Linux https://www.tecmint.com/install-pip-in-linux/
- MacOS This link explains the use of Homebrew package manager and how using it you can install the required python packages and libraries https://medium.com/@GalarnykMichael/how-to-install-and-use-homebrew-80eeb55f73e9
Note:
You may also use pip to install packages.
Here is the link for the same: