Python Programming

Installation

Spyder IDE

These guides will use the scientific python development environment abbreviated spyder as an Integrated Development Environment (IDE). This IDE has a user interface similar to matrix laboratory matlab and is one of the best IDEs for learning the fundamentals of python and usually the preferred IDE for data science.

Anaconda

The Spyder IDE is packaged alongside Python plus numerous other commonly used other python libraries in a installation package known as Anaconda. Anaconda also contains other IDEs such as Jupyter notebooks (but these guides focus on Spyder as an IDE).

I give full instructions on performing a clean installation of Anaconda below for different OS.


Core Python

In this guide I discuss the Spyder 4 user interface and how to use the core python library. You should ensure you are comfortable with this before moving onto additional python libraries.


Core Python Libraries for Data Science

The numpy Library

The numeric python library abbreviated numpy is the most commonly used python library. It is used for array manipulation.


The pandas Library

The python and data analysis library abbreviated pandas is one of the most commonly used libraries in data science. This library allows for dataframe or spreadsheet manipulation or in other words is in essence the Excel of python.


The matplotlib Plotting Library

The matplotlib library is the python plotting and data visualization and is highly based on matlab/octave.


Machine Learning

The SciKit Learn Library (sklearn)

The sklearn library can be used for machine learning applications. I demonstrate some of the fundamentals of machine learning using the standard example datasets.

Guide incomplete (still in progress)


General User Interface (GUI)

The Python Quasar toolkit 5 (PyQt5)

The Python Quasar toolkit 5 library abbreviated as PyQt5 is used to create an interactive General User Interface (GUI). In this guide I reinforce the basics behind object orientated programming and then look at creating some basic GUIs.

Guide incomplete (still in progress)


MatPlotLib: Interpolation

In this section we look at a practical example. Here we practice linear algebra of matrices to interpolate a single point in a curve. We then see how we interpolate a series of points from a data curve using interpolation functions. This also reinforces some of the basics when it comes to plotting.


MatPlotLib: Curve Fitting

In this section we look at curve fitting using the polyfit and polyval functions. Again this gives practice for plotting and here we also introduce subplotting.


MatPlotLib: Trigonometry

Here we practice plotting using right angle triangles. We then plot a series of normalised right angle triangles on a circle to obtain the ratio of sides with respect to the angle. Then use rules of symmetry to obtain equally spaced values around the entire circle. This demonstrates the properties of the sin, cos and tan waveforms.


MatPlotLib: Integration and Differentiation

Here we visualise how we perform integration, employing indexing, plotting techniques and for loops.


Python, NumPy and MatPlotLib: Image Processing Fundamentals

An image as discussed earlier is a 3D array with the 0th page being the intensity of the primary colour red for each pixel, the 1st page being the intensity of the primary colour green for each pixel, the 2nd page being the intensity of the primary colour blue and the 3rd page being the alpha or transparency. All other colours as discussed before are made up using different combinations of red, green and blue. We will look at importing a .png file, deconstructing this 3D array and performing some very basic photo editing by amending the numeric values in this 3D array.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.