This class is a first introduction to Python programming for Data Science.
git
via Anaconda. As soon as
you have installed Anaconda, open the Anaconda console and type
conda install -c anaconda git
. (If you use the default
installer for git
on Windows, you’ll end up with two
different command consoles that use different shells and have different
path settings. This would make the workflow described below less
coherent.)git
, spyder
, pytest
,
sympy
, and scipy
. These packages should pull
in all necessary dependencies. Please check for actual naming of the
distribution packages.The URL to the assignment will be published to the class.
If you follow the assignment URL, Github will ask you to accept the assignment. It will also ask you to associate your user name on Github with your real name. Once you accept the assignment invitation, it creates a repository for you and gives you the URL to your own repository.
You can follow your repository URL to view the assignment. However, to do actual work, you will need to clone the repository to your own computer.
Open an Anaconda console (with alternative installations: any
console that has git in its path settings). Navigate, if necessary, to
an appropriate folder using cd foldername
, and type,
inserting the URL given by Github:
git clone https://github.com/KU-MIDS-MO/abcd
Open Spyder, navigate to the new folder created in the previous step, and do your work.
To run the tests locally on your machine, go back to the console and type
pytest
git commit -am "Assignment is done"
git push
J.V. Guttag, Introduction to Computation and Programming Using Python, third edition, The MIT Press, 2021
C. Hill, Learning scientific programming with Python, second edition, Cambridge University Press, 2020
Introduction
Variables, statements, conditional, loops, functions; integers and floats; equality vs. identity; selected operators, in particular division, floored integer division, and modulo (selected topics from GTG Sections 1.2-1.5)
Euclidean algorithm (see notes); floating point and machine epsilon
Discussion of Assignment 1, Hints for Assignment 2
Lists, tuples, strings, dictionaries (GTG pp. 9-11, 14-16)
Discussion of Assignment 2; Iterators and Generators (GTG 1.8), scope, functions as first-class objects (GTG 1.10), simple Python exceptions (parts of GTG 1.7)
Hints for Assignment 4
Discussion of Assignment 3; Goals of object-oriented programming (GTG 2.1, also see 2.2 for background reading)
Class definitions (GTG 2.3)
Inheritance (GTG 2.4)
Discussion of Assignment 4, hints for Assignments 5+6
Discussion of Assignment 5, file handling, pickling, also see this chapter
No class
Discussion of Assignment 6, Hints for Assignment 7
Introduction to numpy
: array indexing, fancy indexing
(see notes on Numpy indexing by
Andrei Caragea, for an broader overview, see this Introduction to the
Scipy Stack)
Introduction to plotting using matplotlib
Least square fitting and simple root solving (see notes by Andrei Caragea)
Random numbers
Applications: Random walk and simple Monte Carlo (see notes by Andrei Caragea)
Matrix arithmetic and an application to graph adjacency matrices
Solving linear systems (see notes by Andrei Caragea)
Hints for Assignment 10/11; Matrix norm and condition number (see Joh, Chapter 5, Section “Square Systems”; the Wikipedia entries on the matrix Norm and condition number are very comprehensive, but go far beyond what is required here)
Hints for Assignment 10/11; Ill-conditioned linear systems (Example from Joh, Chapter 5, Section “Square Systems”)
Inner and outer products (for outer products using broadcasting, see Example 4 from Array Broadcasting in Numpy); Interpolation and the Vandermonde matrix, construction of the Vandermonde matrix in Numpy as a generalized outer product; Discussion of solutions to Assignment 10/11
Eigenvalues and eigenvectors (informal introduction), eigenvalues in Numpy, computation of the dominant eigenvalue/eigenvector pair using power iteration, connection to matrix norm and condition number
Introduction to sympy (Joh, Chapter 3; there are many good tutorials, this one is very well written, some of the more advanced examples can be ignored for now; there are others)
no class, please attend the session on Feb 2
Hints for Assignment 13, discussion and presentation of past assignments (start)
Discussion and presentation of past assignments (ctd.)