Python 101
The goal of this course is to teach beginners how to solve real life problems using a computer.
Emphasis is given on autonomy (e.g. searching the web for answers), and finding a solution even if it is not the canonical one.
Syllabus
About the course
Python basics
- Evaluating code
- Finding help
- Syntax basics
challenge
This was just about copy-pasting some code
assignment
Do both parts of the first challenge of any year on https://adventofcode.com/.
challenge "Simon says"
See how to solve it here.
assignment
Do both parts of the first challenge of another year on https://adventofcode.com/ or the first few problems of https://projecteuler.net/.
challenge "Collatz"
See how to solve it here.
Data analytics and visualization
- pandas
- matplotlib
- seaborn
- tidy data
- DSL
- grammar of graphics
- statistics
assignment
- Read: https://vita.had.co.nz/papers/tidy-data.pdf
- Read: https://vita.had.co.nz/papers/layered-grammar.html
- Find a dataset you care about, and analyse it using pandas in a notebook, drawing a funny, or interesting, or absurd, or unexpected, or important conclusion from the data. Don't forget to intersperse text between your code blocks to talk about your data. The whole thing should not be too long. basics
challenge
There was no challenge that day
assignment
- Use
seaborn
to draw a a funny, or interesting, or absurd, or unexpected, or important graph from a piece of data, either the dataset of the last assignment, or a new one.
challenge "Ice Cream"
See how to solve it here.
Constraint programming
- Comparative advantage
- Operations research
- Linear programming and the simplex algorithm
- Convex optimization
- Combinatorics
assignment
- Solve,relying only on your own code and the standard library, the optimal mining problem:
- generate a set of random (weight, fee) pairs,
- within a hard weight limit of, say, 200, try to get the maximum sum of fees
- try to play with the weight limit, and the weight distribution to see when your solution becomes untractable
- (optional) try to devise a solution that works for large problem.
- Solution
You can find a Pythonic way of solving here.
challenge "Drawer"
See how to solve it here.
challenge "Chemical plant"
Solution to be posted on
assignment
- Find in your day to day life, or in your past professional experience, a problem that can be optimized using ORtools.
- You may stay within the Linear Programming framework, or use another solver from the ORtools package.
- It can be an actual problem, the solution to which will make your day to day life better, or if you are unable to find such a problem, you can build a contrived one from a silly example and solve that. The point is to train your ability to translate business constraints into equations, and to think critically about the solution.
- It can be very interesting to try to solve a multi-objective problem by devising an objective function that is the sum of competing objectives.
- See the resources below if you want to know more about this topic.
Satisfiability
Machine Learning
Web scraping
Resources
- Anki deck (Also available on AnkiWeb, last updated )
- Snippets: Some pieces of code I showed in class can be found here.
- Finding datasets:
- https://www.imdb.com/interfaces/
- https://research.spotify.com/datasets
- https://web.archive.org/web/20090925184737/
- http://archive.ics.uci.edu/ml/datasets/Netflix+Prize
- https://www.kaggle.com/datasets
- https://www.data.gouv.fr/fr/
- https://datasetsearch.research.google.com/
- https://paperswithcode.com/datasets
- https://old.reddit.com/r/Python/comments/lcexoa/i_made_a_finance_database_with_over_180000/
- https://www.movebank.org
- https://github.com/rfordatascience/tidytuesday
- https://www.wikidata.org/wiki/Wikidata:Main_Page
- https://github.com/awesomedata/awesome-public-datasets
- https://github.com/public-apis/public-apis
- https://docs.google.com/spreadsheets/d/1wZhPLMCHKJvwOkP4juclhjFgqIY8fQFMemwKL2c64vk/edit#gid=0
- To find a dataset about X, google keywords such as:
- X dataset
- X datadump
- X database
- X open data
- X csv data
- X machine learning training
- If you find a good dataset, please let me know and I'll add it here.
- Constraint optimization:
- See some examples of easy business problems to turn into constraints here https://www.purplemath.com/modules/linprog2.htm
- See more academic/pedagogical examples, but with a straightforward industrial flavor here https://github.com/Alexander-Schiendorfer/cp-examples
- Hakank's page is full of links and resources about Constraint programming:
- http://www.hakank.org/
- He's also an active user on Hacker News: https://news.ycombinator.com/threads?id=hakank https://news.ycombinator.com/favorites?id=hakank
- The following series of courses on Coursera will let you deep dive on the topic. They do not use Python but what you will learn will be transferable to ORtools easily. I took those courses and I can't recommend them enough, they are very well made and enjoyable ! They are masters-level classes, and the difficulty is increasing, so check them out, but don't beat yourselves up if you can't solve everything easily !
- The theory of constraints builds on the idea that only one constraint is binding at a time, and one should focus on identifying and removing it. A gentle introduction can be found in novelized form