├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── css ├── bootstrap.min.css ├── font-awesome.min.css ├── highlight.tomorrow-night.css └── main.css ├── fonts ├── FontAwesome.otf ├── fontawesome-webfont.eot ├── fontawesome-webfont.svg ├── fontawesome-webfont.ttf └── fontawesome-webfont.woff ├── getstarted.html ├── homework.html ├── hw ├── 2016_spring │ ├── hw1.zip │ └── hw1 │ │ ├── README.txt │ │ ├── matrix.py │ │ ├── matrix_sol.py │ │ ├── run.py │ │ └── util.py ├── 2018_fall │ ├── .gitignore │ ├── hw1 │ │ ├── hw1.pdf │ │ ├── hw1.tex │ │ ├── ipynb │ │ │ ├── hw1_gen.ipynb │ │ │ └── sbm.png │ │ ├── sbm.csv │ │ └── solution │ │ │ ├── hw1.py │ │ │ └── sbm.png │ └── hw2 │ │ ├── abalone.data │ │ ├── hw2.pdf │ │ ├── hw2.tex │ │ ├── ipynb │ │ ├── hw2.ipynb │ │ ├── knn.png │ │ ├── pred.png │ │ └── regression.png │ │ └── solution │ │ ├── hw2.py │ │ └── regression.png └── 2019_winter │ ├── CME193-Assignment1.ipynb │ └── CME193-Assignment2.ipynb ├── index.html ├── jupyter.html ├── lectures.html ├── nb ├── .gitignore ├── 2016_spring │ ├── lecture-1.ipynb │ ├── lecture-1.slides.html │ ├── lecture-2.ipynb │ ├── lecture-2.slides.html │ ├── lecture-3.ipynb │ ├── lecture-3.slides.html │ ├── lecture-4.ipynb │ ├── lecture-4.slides.html │ ├── lecture-5.ipynb │ ├── lecture-5.slides.html │ ├── lecture-6.ipynb │ ├── lecture-6.slides.html │ ├── lecture-7.ipynb │ ├── lecture-7.slides.html │ └── lecture-8.ipynb ├── 2018_fall │ ├── Lecture4-Optimization-Using-Python-SciPy-InClass.ipynb │ ├── Lecture4-Optimization-Using-Python-SciPy.ipynb │ ├── Lecture5-Pandas.ipynb │ ├── Lecture5-supplement-solution.ipynb │ ├── Lecture5-supplement.ipynb │ ├── Lecture6-Scikit-learn.ipynb │ ├── Lecture6-supplement-solution.ipynb │ ├── Lecture6-supplement.ipynb │ ├── Lecture7-Optimization-Using-Python-ORTools-InClass.ipynb │ ├── Lecture7-Optimization-Using-Python-ORTools.ipynb │ ├── Lecture8-solutions.ipynb │ ├── Lecture8.ipynb │ ├── Lecture_1.ipynb │ ├── Lecture_2.ipynb │ ├── Lecture_3_scipy.ipynb │ ├── data │ │ ├── co2_mm_mlo.txt │ │ └── iris.csv │ ├── img │ │ ├── iris_knn.png │ │ └── splitApplyCombine.png │ ├── lecture_1 │ │ └── ex_1.md │ └── lecture_2 │ │ └── test_script.py ├── 2018_spring │ ├── Lecture1.ipynb │ ├── Lecture2.ipynb │ ├── Lecture3.ipynb │ ├── Lecture4.ipynb │ ├── Lecture5.ipynb │ ├── Lecture6.ipynb │ ├── Lecture7-climate.ipynb │ ├── Lecture7-face-classification.ipynb │ ├── Lecture7.ipynb │ ├── Lecture8.ipynb │ ├── Lecture8_old.ipynb │ └── Lecture9.ipynb ├── 2019_spring │ ├── CME193_Homework_1.ipynb │ ├── CME193_Homework_1_Solution.ipynb │ ├── CME193_Homework_2.ipynb │ ├── CME193_Homework_2_Solution.ipynb │ ├── Lecture_1.ipynb │ ├── Lecture_1_post.ipynb │ ├── Lecture_2.ipynb │ ├── Lecture_2_post.ipynb │ ├── Lecture_3.ipynb │ ├── Lecture_3_post.ipynb │ ├── Lecture_4.ipynb │ ├── Lecture_4_post.ipynb │ ├── Lecture_5.ipynb │ ├── Lecture_5_post.ipynb │ ├── Lecture_6.ipynb │ ├── Lecture_6_post.ipynb │ ├── Lecture_7.ipynb │ ├── Lecture_7_post.ipynb │ └── Lecture_8.ipynb ├── 2019_winter │ ├── Lecture4-Optimization-Using-Python-SciPy-InClass.ipynb │ ├── Lecture4-Optimization-Using-Python-SciPy.ipynb │ ├── Lecture5-Pandas.ipynb │ ├── Lecture5-supplement-solution.ipynb │ ├── Lecture5-supplement.ipynb │ ├── Lecture6-Scikit-learn.ipynb │ ├── Lecture6-supplement-solution.ipynb │ ├── Lecture6-supplement.ipynb │ ├── Lecture7-Numpy-revision-and-practice.ipynb │ ├── Lecture7-Optimization-Using-Python-ORTools-InClass.ipynb │ ├── Lecture7-Optimization-Using-Python-ORTools.ipynb │ ├── Lecture8-pytorch.ipynb │ ├── Lecture8-slides.pdf │ ├── Lecture8-solutions.ipynb │ ├── Lecture8.ipynb │ ├── Lecture_1.ipynb │ ├── Lecture_2.ipynb │ ├── Lecture_3.ipynb │ ├── Lecture_3_scipy.ipynb │ ├── Lecture_4.ipynb │ ├── data │ │ ├── co2_mm_mlo.txt │ │ └── iris.csv │ ├── img │ │ ├── iris_knn.png │ │ └── splitApplyCombine.png │ ├── lecture_1 │ │ └── ex_1.md │ └── lecture_2 │ │ └── test_script.py └── nb-assets │ └── img │ ├── broadcasting.png │ └── python.png ├── syllabus.html └── web ├── LICENSE ├── couscous.yml ├── css ├── bootstrap.min.css ├── font-awesome.min.css ├── highlight.tomorrow-night.css └── main.css ├── default.twig ├── fonts ├── FontAwesome.otf ├── fontawesome-webfont.eot ├── fontawesome-webfont.svg ├── fontawesome-webfont.ttf └── fontawesome-webfont.woff ├── getstarted.md ├── homework.md ├── index.md ├── jupyter.md ├── lectures.md └── syllabus.md /.gitignore: -------------------------------------------------------------------------------- 1 | web/.couscous/ 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "nb/reveal.js"] 2 | path = nb/reveal.js 3 | url = https://github.com/hakimel/reveal.js 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Couscous 2 | 3 | Copyright (C) Matthieu Napoli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial 12 | portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 18 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CME 193 - Scientific Python 2 | 3 | Please visit the course website: [http://cme193.stanford.edu](http://cme193.stanford.edu) 4 | -------------------------------------------------------------------------------- /css/highlight.tomorrow-night.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Night Theme */ 2 | /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ 3 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 4 | /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ 5 | .tomorrow-comment, pre .comment, pre .title { 6 | color: #969896; 7 | } 8 | 9 | .tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo { 10 | color: #cc6666; 11 | } 12 | 13 | .tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant { 14 | color: #de935f; 15 | } 16 | 17 | .tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute { 18 | color: #f0c674; 19 | } 20 | 21 | .tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata { 22 | color: #b5bd68; 23 | } 24 | 25 | .tomorrow-aqua, pre .css .hexcolor { 26 | color: #8abeb7; 27 | } 28 | 29 | .tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title { 30 | color: #81a2be; 31 | } 32 | 33 | .tomorrow-purple, pre .keyword, pre .javascript .function { 34 | color: #b294bb; 35 | } 36 | 37 | pre code { 38 | display: block; 39 | background: #1d1f21; 40 | color: #c5c8c6; 41 | font-family: Menlo, Monaco, Consolas, monospace; 42 | line-height: 1.5; 43 | border: 1px solid #ccc; 44 | padding: 10px; 45 | } 46 | -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 19px; 3 | } 4 | 5 | main { 6 | margin-top: 90px; 7 | } 8 | 9 | section { 10 | margin-bottom: 50px; 11 | } 12 | 13 | h1, h2, h3, h4 { 14 | color: #df691a; 15 | } 16 | h3 { 17 | font-size: 23px; 18 | } 19 | 20 | li { 21 | margin-bottom: 3px; 22 | } 23 | 24 | img { 25 | max-width: 100%; 26 | } 27 | 28 | header.navbar { 29 | opacity: 0.9; 30 | } 31 | .navbar .navbar-brand { 32 | font-size: 28px; 33 | height: auto; 34 | line-height: 50px; 35 | margin-left: 20px; 36 | color: #df691a; 37 | } 38 | .navbar a.navbar-brand:hover { 39 | color: #df691a; 40 | } 41 | .navbar .navbar-brand small { 42 | font-size: 18px; 43 | font-weight: 300; 44 | margin-left: 10px; 45 | color: white; 46 | } 47 | 48 | @media (min-width: 768px) { 49 | #sidebar { 50 | position:fixed; 51 | } 52 | } 53 | @media (max-width: 960px) { 54 | body { 55 | font-size: 17px; 56 | } 57 | pre { 58 | font-size: 12px; 59 | } 60 | } 61 | 62 | .page-header { 63 | margin-top: 0; 64 | } 65 | 66 | #sidebar .github-star { 67 | margin-top: 20px; 68 | margin-left: 50px; 69 | } 70 | 71 | #sidebar .text-muted { 72 | color: #859AAF; 73 | } 74 | 75 | pre { 76 | padding: 0; 77 | border-color: #3D5166; 78 | background-color: #1D2B3A; 79 | border-radius: 4px; 80 | margin: 15px; 81 | } 82 | pre code { 83 | border: none; 84 | background-color: #1D2B3A; 85 | } 86 | 87 | code { 88 | font-size: 85%; 89 | padding: 4px 4px 1px; 90 | margin: 0 4px; 91 | border-radius: 3px; 92 | color: #c5c8c6; 93 | border: solid 1px #3D5166; 94 | background-color: #1D2B3A; 95 | white-space: pre-wrap; 96 | white-space: -moz-pre-wrap; 97 | word-wrap: break-word; 98 | } 99 | -------------------------------------------------------------------------------- /fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icme/cme193/3ed008f6e0951b80faf1d77c9542ae0dd925691d/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icme/cme193/3ed008f6e0951b80faf1d77c9542ae0dd925691d/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icme/cme193/3ed008f6e0951b80faf1d77c9542ae0dd925691d/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icme/cme193/3ed008f6e0951b80faf1d77c9542ae0dd925691d/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /homework.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |\n", 57 | " | party | \n", 58 | "Vote_0 | \n", 59 | "Vote_1 | \n", 60 | "Vote_2 | \n", 61 | "Vote_3 | \n", 62 | "Vote_4 | \n", 63 | "Vote_5 | \n", 64 | "Vote_6 | \n", 65 | "Vote_7 | \n", 66 | "Vote_8 | \n", 67 | "Vote_9 | \n", 68 | "Vote_10 | \n", 69 | "Vote_11 | \n", 70 | "Vote_12 | \n", 71 | "Vote_13 | \n", 72 | "Vote_14 | \n", 73 | "Vote_15 | \n", 74 | "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", 79 | "republican | \n", 80 | "n | \n", 81 | "y | \n", 82 | "n | \n", 83 | "y | \n", 84 | "y | \n", 85 | "y | \n", 86 | "n | \n", 87 | "n | \n", 88 | "n | \n", 89 | "y | \n", 90 | "? | \n", 91 | "y | \n", 92 | "y | \n", 93 | "y | \n", 94 | "n | \n", 95 | "y | \n", 96 | "
1 | \n", 99 | "republican | \n", 100 | "n | \n", 101 | "y | \n", 102 | "n | \n", 103 | "y | \n", 104 | "y | \n", 105 | "y | \n", 106 | "n | \n", 107 | "n | \n", 108 | "n | \n", 109 | "n | \n", 110 | "n | \n", 111 | "y | \n", 112 | "y | \n", 113 | "y | \n", 114 | "n | \n", 115 | "? | \n", 116 | "
2 | \n", 119 | "democrat | \n", 120 | "? | \n", 121 | "y | \n", 122 | "y | \n", 123 | "? | \n", 124 | "y | \n", 125 | "y | \n", 126 | "n | \n", 127 | "n | \n", 128 | "n | \n", 129 | "n | \n", 130 | "y | \n", 131 | "n | \n", 132 | "y | \n", 133 | "y | \n", 134 | "n | \n", 135 | "n | \n", 136 | "
3 | \n", 139 | "democrat | \n", 140 | "n | \n", 141 | "y | \n", 142 | "y | \n", 143 | "n | \n", 144 | "? | \n", 145 | "y | \n", 146 | "n | \n", 147 | "n | \n", 148 | "n | \n", 149 | "n | \n", 150 | "y | \n", 151 | "n | \n", 152 | "y | \n", 153 | "n | \n", 154 | "n | \n", 155 | "y | \n", 156 | "
4 | \n", 159 | "democrat | \n", 160 | "y | \n", 161 | "y | \n", 162 | "y | \n", 163 | "n | \n", 164 | "y | \n", 165 | "y | \n", 166 | "n | \n", 167 | "n | \n", 168 | "n | \n", 169 | "n | \n", 170 | "y | \n", 171 | "? | \n", 172 | "y | \n", 173 | "y | \n", 174 | "y | \n", 175 | "y | \n", 176 | "
This course is recommended for students who are familiar with programming at least at the level of CS106A and want to translate their programming knowledge to Python with the goal of becoming proficient in the scientific computing and data science stack. Lectures will be interactive with a focus on real world applications of scientific computing. Technologies covered include Numpy, SciPy, Pandas, Scikit-learn, and others. Topics will be chosen from Linear Algebra, Optimization, Machine Learning, and Data Science. Prior knowledge of programming will be assumed, and some familiarity with Python is helpful, but not mandatory.
83 |This course starts the second week of the quarter on Tuesday 1/15
85 |CME 193 - Introduction to Scientific Python - Winter 2019
86 |Instructor:
93 | Anjan Dwaraknath (anjandn {at} stanford {dot} edu
)
Office hours:
95 |There are no formal prerequisites. This means we won't check your previous programming experience.
101 |However, the course material will assume prior programming experience. Ideally, you already are comfortable programming in at least one language (C, C++, fortran, Julia, Matlab, R, Java, ...), and perhaps have seen some basic Python before.
102 |If you haven't worked with Python in the past, you may wish to complete an introduction to Python on Codeacademy 103 | and/or Udacity.
104 |This is a course on scientific computing with Python. This will assume you
106 |This short course runs for four weeks of the quarter (starting 1/15) and is offered each quarter during the academic year.
112 |Lectures will be interactive using Jupyter Notebooks with a focus on learning by example, and assignments will be application-driven.
113 |We'll typically devote some time during class to working on exercises, so you can ask for help if you're stuck.
114 |This a 1-unit workshop style course, offered on a credit/no-credit basis. To receive credit:
116 |The goal is to give you some practice and experience with the content of the course, without overwhelming you with work.
121 |This course is intended to be collaborative. You can (and should) work with other students in class and on homework. You should turn in your own solutions (don't copy others). If you worked closely with someone or found an answer on the web, please acknowledge the source of your solution.
124 |Students with Documented Disabilities: Students who may need an academic accommodation based on the impact of a disability must initiate the request with the Office of Accessible Education (OAE). Professional staff will evaluate the request with required documentation, recommend reasonable accommodations, and prepare an Accommodation Letter for faculty. Unless the student has a temporary disability, Accommodation letters are issued for the entire academic year. Students should contact the OAE as soon as possible since timely notice is needed to coordinate accommodations. The OAE is located at 563 Salvatierra Walk (phone: 723-1066, URL: https://oae.stanford.edu/).
126 |note all commands on this page are invoked from a bash shell (terminal), not from an interactive Python session.
82 |Jupyter notebooks are used to mix code and markdown (for exposition) in a single place.
84 |Jupyter comes bundled with Anaconda, but you can download it for whatever python you are using using pip
(doesn't have to be anaconda python).
From a terminal:
86 |pip install jupyter
87 | Note that Jupyter is not Python. You can use python in a variety of other ways (e.g., through the command line). Additionally, you can use Jupyter notebooks with other programming languages.
88 |Once you have Jupyter installed, you can launch a notebook server.
90 |From a terminal:
91 |jupyter notebook
92 | This should launch a notebook server on your computer, and open a tab on your browser. You can then navigate to the folder holding the notebook you'd like to run. Alternatively, you first navigate to the folder you want to be in, then launch the notebook server.
93 |Note You can launch Jupyter from the Anaconda launcher. This may work, but I advise that you don't rely on the launcher and instead do it from a terminal.
94 |You don't need to install Jupyter in every virtual environment. However, you do need to install a ipykernel
for every virtual environment. This is what lets Jupyter know how to run this version of Python.
First, you may wish to install nb_conda
Next, you need to install an ipykernel
for your virtual environment. This looks like the following:
From a terminal:
99 |conda install nb_conda
100 | source activate cme193 # cme193 virtual env
101 | conda install ipykernel # installs a python kernel for this environment
102 | Now, when you launch a Jupyter notebook server (even without your environment activated), you should see a Python [conda env:cme193]
option in the kernel menu.
Disclaimer: these lecture notebooks are subject to change and can be updated any time. 83 | Please check regularly, as lectures are added as we progress.
84 |Content from previous offerings of the course (as-is)
96 |This is a course on scientific computing using Python. We'll cover aspects of the Python language as they are relevant to the material. The following schedule should be seen as a high-level guide to what we'll do in 8 lectures, but is not set in stone.
83 |We'll intersperse the visualization libraries:
94 |