├── .gitignore ├── LICENSE ├── README.md ├── _config.yml ├── assets └── css │ └── style.scss ├── notebooks ├── .DS_Store ├── .gitignore ├── 01_python_basics.ipynb ├── 01_python_basics_corrected.ipynb ├── 02_sklearn │ ├── 01-Preliminaries.ipynb │ ├── 02.1-Machine-Learning-Intro.ipynb │ ├── 02.2-Basic-Principles.ipynb │ ├── 03.1-Classification-SVMs.ipynb │ ├── 03.2-Regression-Forests.ipynb │ ├── 04.1-Dimensionality-PCA.ipynb │ ├── 04.2-Clustering-KMeans.ipynb │ ├── 04.3-Density-GMM.ipynb │ ├── 05-Validation.ipynb │ ├── 06-Pipeline.ipynb │ ├── LICENSE │ ├── README.md │ ├── URL.ipynb │ ├── fig_code │ │ ├── ML_flow_chart.py │ │ ├── Untitled.ipynb │ │ ├── __init__.py │ │ ├── data.py │ │ ├── figures.py │ │ ├── helpers.py │ │ ├── linear_regression.py │ │ ├── sgd_separator.py │ │ └── svm_gui.py │ ├── images │ │ ├── data-layout.png │ │ ├── iris_setosa.jpg │ │ ├── iris_versicolor.jpg │ │ └── iris_virginica.jpg │ └── solutions │ │ └── 06-Pipeline-1.py ├── 03_optimization.ipynb ├── 03_optimization_corrected.ipynb ├── 04_pytorch │ ├── 01_introduction_to_pytorch.ipynb │ ├── 02_simple_neural_network.ipynb │ ├── 02_simple_neural_network_solution.ipynb │ ├── 03_convolutional_neural_network_mnist.ipynb │ └── 03_convolutional_neural_network_mnist_solution.ipynb ├── 05_sql.pdf ├── 05_sql_solutions.zip └── README.md └── slides ├── 01_machine_learning_successes ├── drawings │ ├── drawing.svg │ └── drawing.svg.2020_08_30_22_59_12.0.svg ├── images │ ├── WaveNet.gif │ ├── ada_lovelace.jpg │ ├── alan_turing.jpg │ ├── autonomous.png │ ├── behavior.png │ ├── brain.png │ ├── cambridge_analytica.png │ ├── china.png │ ├── clearview.jpg │ ├── criteo.png │ ├── dermato.png │ ├── edsger_dijkstra.jpg │ ├── faceid.jpg │ ├── frameworks.png │ ├── games.png │ ├── generator.png │ ├── gpt3.jpg │ ├── gpu_tpu.png │ ├── images.png │ ├── intelligence.png │ ├── latent.png │ ├── learning1.png │ ├── learning2.png │ ├── learning3.png │ ├── logo_ens_psl_couleur.png │ ├── machine.png │ ├── machine_learning.png │ ├── minsky.jpg │ ├── neural_networks.png │ ├── neuron.png │ ├── nlp.png │ ├── nlp2.png │ ├── nlp_vision.png │ ├── nvidia_celeb.jpg │ ├── papers.jpg │ ├── revenues.jpg │ ├── rl.png │ ├── rosenblatt.jpeg │ ├── shannon.jpg │ ├── speech.png │ ├── text.png │ ├── vision.png │ ├── vision2.png │ ├── vision_translation.png │ └── von_neumann.gif ├── index.html ├── slides.css ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 02_intro_to_machine_learning ├── figures │ ├── README.md │ ├── bagging.svg │ ├── bagging0.svg │ ├── bagging0_cross.svg │ ├── bagging_cross.svg │ ├── bagging_fit.svg │ ├── bagging_line.svg │ ├── bagging_overfit.svg │ ├── bagging_reg_blue.svg │ ├── bagging_reg_blue_grey.svg │ ├── bagging_reg_data.svg │ ├── bagging_reg_grey.svg │ ├── bagging_reg_grey_fitted.svg │ ├── bagging_trees.svg │ ├── bagging_trees_predict.svg │ ├── bagging_underfit.svg │ ├── bagging_vote.svg │ ├── boosting │ │ ├── boosting_iter1.svg │ │ ├── boosting_iter2.svg │ │ ├── boosting_iter3.svg │ │ ├── boosting_iter4.svg │ │ ├── boosting_iter_orange1.svg │ │ ├── boosting_iter_orange2.svg │ │ ├── boosting_iter_orange3.svg │ │ ├── boosting_iter_orange4.svg │ │ ├── boosting_iter_sized1.svg │ │ ├── boosting_iter_sized2.svg │ │ ├── boosting_iter_sized3.svg │ │ └── boosting_iter_sized4.svg │ ├── boosting0.svg │ ├── boosting0_cross.svg │ ├── boosting1.svg │ ├── boosting2.svg │ ├── boosting3.svg │ ├── boosting_reg_blue.svg │ ├── boosting_reg_data.svg │ ├── boosting_reg_grey.svg │ ├── boosting_trees1.svg │ ├── boosting_trees2.svg │ ├── boosting_trees3.svg │ ├── bossting_reg_blue.svg │ ├── categorical.svg │ ├── cross_validation.png │ ├── different_models_complex_16.svg │ ├── different_models_complex_4.svg │ ├── dt_fit.svg │ ├── dt_overfit.svg │ ├── dt_underfit.svg │ ├── inference-phase.png │ ├── iris-silhouette.svg │ ├── iris-silhouette_gray.svg │ ├── iris_petal_length_cm_hist.svg │ ├── iris_petal_width_cm_hist.svg │ ├── iris_sepal_length_cm_hist.svg │ ├── iris_sepal_width_cm_hist.svg │ ├── legend_irises.svg │ ├── lin_not_separable.svg │ ├── lin_reg_2_points.svg │ ├── lin_reg_2_points_best_ridge.svg │ ├── lin_reg_2_points_best_ridge_grey.svg │ ├── lin_reg_2_points_no_penalty.svg │ ├── lin_reg_2_points_no_penalty_grey.svg │ ├── lin_reg_2_points_ridge.svg │ ├── lin_reg_2_points_ridge_grey.svg │ ├── lin_reg_3D.svg │ ├── lin_separable.svg │ ├── linear_data.svg │ ├── linear_fit.svg │ ├── linear_fit_red.svg │ ├── linear_ols.svg │ ├── linear_ols_test.svg │ ├── linear_splines.svg │ ├── linear_splines_test.svg │ ├── logistic_2D.svg │ ├── logistic_2D_C0.001.svg │ ├── logistic_2D_C1.svg │ ├── logistic_3D.svg │ ├── logistic_color.svg │ ├── logistic_curve.png │ ├── multinomial.svg │ ├── ols_simple.svg │ ├── ols_simple_test.svg │ ├── ols_test.svg │ ├── people.svg │ ├── plot_iris_visualization.py │ ├── plot_overfit_underfit.py │ ├── plot_slide_linear.py │ ├── plot_splines.py │ ├── plot_trees.py │ ├── polynomial_learning_curve_1179.svg │ ├── polynomial_learning_curve_145.svg │ ├── polynomial_learning_curve_42.svg │ ├── polynomial_learning_curve_6766.svg │ ├── polynomial_overfit.svg │ ├── polynomial_overfit_0.svg │ ├── polynomial_overfit_1.svg │ ├── polynomial_overfit_2.svg │ ├── polynomial_overfit_5.svg │ ├── polynomial_overfit_9.svg │ ├── polynomial_overfit_assymptotic.svg │ ├── polynomial_overfit_ntrain_1179.svg │ ├── polynomial_overfit_ntrain_145.svg │ ├── polynomial_overfit_ntrain_42.svg │ ├── polynomial_overfit_ntrain_6766.svg │ ├── polynomial_overfit_simple.svg │ ├── polynomial_overfit_simple_legend.svg │ ├── polynomial_overfit_test_1.svg │ ├── polynomial_overfit_test_2.svg │ ├── polynomial_overfit_test_5.svg │ ├── polynomial_overfit_test_9.svg │ ├── polynomial_validation_curve.svg │ ├── polynomial_validation_curve_1.svg │ ├── polynomial_validation_curve_15.svg │ ├── polynomial_validation_curve_2.svg │ ├── polynomial_validation_curve_5.svg │ ├── polynomial_validation_curve_9.svg │ ├── randomized_search_results.csv │ ├── splines_cubic.svg │ ├── splines_cubic_test.svg │ ├── splines_test.svg │ ├── style_figs.py │ ├── supervised.png │ ├── target_bias.svg │ ├── target_variance.svg │ ├── training-phase.png │ ├── tree2D_1split.svg │ ├── tree2D_2split.svg │ ├── tree2D_3split.svg │ ├── tree_blue_orange1.svg │ ├── tree_blue_orange2.svg │ ├── tree_blue_orange3.svg │ ├── tree_example.svg │ ├── tree_regression1.svg │ ├── tree_regression2.svg │ ├── tree_regression3.svg │ ├── unsupervised.png │ └── workflow.png ├── index.html ├── iris_setosa.jpg ├── iris_versicolor.jpg ├── iris_virginica.jpg ├── slides.css ├── sphx_glr_plot_bias_variance_001.png ├── sphx_glr_plot_bias_variance_003.png ├── sphx_glr_plot_bias_variance_004.png ├── sphx_glr_plot_bias_variance_006.png ├── sphx_glr_plot_iris_knn_001.png ├── sphx_glr_plot_iris_scatter_001.png ├── sphx_glr_plot_polynomial_regression_001.png ├── sphx_glr_plot_polynomial_regression_002.png ├── sphx_glr_plot_svm_non_linear_001.png ├── sphx_glr_plot_svm_non_linear_002.png ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 03_machine_learning_models ├── boston_figs.py ├── decision_trees.py ├── forest.py ├── images │ ├── Colored_neural_network.svg │ ├── boston_1.png │ ├── boston_2.png │ ├── boston_3.png │ ├── boston_31.png │ ├── boston_4.png │ ├── boston_5.png │ ├── decision_trees.png │ ├── decision_trees1.png │ ├── decision_trees2.png │ ├── decision_trees3.png │ ├── decision_trees4.png │ ├── decision_trees5.png │ ├── decision_trees6.png │ ├── forest_picture.png │ ├── iris.png │ ├── iris_1.png │ ├── iris_10.png │ ├── iris_11.png │ ├── iris_12.png │ ├── iris_13.png │ ├── iris_14.png │ ├── iris_15.png │ ├── iris_2.png │ ├── iris_3.png │ ├── iris_4.png │ ├── iris_5.png │ ├── iris_6.png │ ├── iris_7.png │ ├── iris_8.png │ ├── iris_9.png │ ├── linear_model1.png │ ├── linear_model2.png │ ├── linear_model3.png │ ├── linear_model4.png │ ├── logo_ens_psl_couleur.png │ ├── nn.png │ ├── nn_one_2.png │ ├── nn_one_3.png │ ├── nn_one_4.png │ ├── nn_one_5.png │ ├── nn_one_6.png │ ├── nn_two_2.png │ ├── nn_two_3.png │ ├── nn_two_4.png │ ├── nn_two_5.png │ ├── nn_two_6.png │ ├── trees.png │ ├── trees_1.png │ ├── trees_10.png │ ├── trees_11.png │ ├── trees_12.png │ ├── trees_13.png │ ├── trees_14.png │ ├── trees_15.png │ ├── trees_16.png │ ├── trees_17.png │ ├── trees_18.png │ ├── trees_19.png │ ├── trees_2.png │ ├── trees_20.png │ ├── trees_3.png │ ├── trees_4.png │ ├── trees_5.png │ ├── trees_6.png │ ├── trees_7.png │ ├── trees_8.png │ └── trees_9.png ├── index.html ├── iris_figs.py ├── linear_models.py ├── neural_nets.py ├── slides.css ├── tree.svg ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 04_scikit_learn ├── drawings │ ├── drawing.svg │ ├── g5387.png │ └── transform.png ├── images │ ├── confusion_matrix.png │ ├── logo_ens_psl_couleur.png │ ├── matplotlib.webp │ ├── ml_map.png │ ├── pandas.png │ └── seaborn.png ├── index.html ├── kmeans.ipynb ├── kmeans0.png ├── kmeans1.png ├── kmeans2.png ├── kmeans3.png ├── kmeans_over.png ├── kmeans_under.png ├── slides.css ├── transformers.ipynb ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 05_optimization_linear_models ├── figures │ ├── convex_function.png │ └── stationary_point.png ├── gd_illust.py ├── images │ ├── gd_illust.png │ ├── gd_illust_1.png │ ├── gd_illust_2.png │ ├── gd_illust_3.png │ ├── gd_illust_4.png │ ├── gd_illust_5.png │ ├── gd_illust_6.png │ ├── gd_illust_7.png │ ├── gd_illust_8.png │ ├── gd_loss.png │ └── gd_loss1.png ├── index.html ├── slides.css ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 06_optimization_general ├── images │ ├── lbfgs.png │ ├── logo_ens_psl_couleur.png │ ├── newton_cv.png │ ├── quadratic.png │ ├── quadratic1.png │ ├── sgd_illust.png │ ├── sgd_illust_1.png │ ├── sgd_illust_2.png │ ├── sgd_illust_3.png │ ├── sgd_illust_4.png │ ├── sgd_illust_5.png │ ├── sgd_illust_6.png │ ├── sgd_illust_7.png │ ├── sgd_illust_8.png │ ├── sgd_loss.png │ └── sgd_loss1.png ├── index.html ├── lbfgs.py ├── loss_illust.py ├── quadratic.py ├── sgd_illust.py ├── slides.css ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 07_deep_learning ├── image.png ├── images.py ├── images │ ├── Colored_neural_network.svg │ ├── Logo_Master_Datascience.png │ ├── alexnet.png │ ├── archievol.png │ ├── architectures.png │ ├── assembled-resnet.png │ ├── augmented-cat.png │ ├── convmap1.svg │ ├── convmap1_dims.svg │ ├── convmap2.svg │ ├── convmap3.svg │ ├── convmap4.svg │ ├── convmap_dims.svg │ ├── deeper.png │ ├── efficientnet.png │ ├── heuritech-logo.png │ ├── inception1.png │ ├── inception2.png │ ├── inria-logo.png │ ├── kernel.svg │ ├── lecunconv.png │ ├── lenet.png │ ├── logo_ens_psl_couleur.png │ ├── maxpool.svg │ ├── no_padding_strides.gif │ ├── not-augmented-cat.png │ ├── numerical_no_padding_no_strides.gif │ ├── numerical_no_padding_no_strides_00.png │ ├── performanceSOTA.png │ ├── pooling.png │ ├── residualblock.png │ ├── resnet.png │ ├── same_padding_no_strides.gif │ ├── templateconvmap.svg │ ├── vgg.png │ └── vision.png ├── index.html ├── patches.png ├── slides.css ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 08_unsupervised_learning ├── correlation.py ├── digits_spectrum.py ├── dim_red.py ├── factorization.py ├── ica.py ├── images │ ├── activ.png │ ├── cats.png │ ├── catsndogs.png │ ├── correlation_%d.png │ ├── correlation_0.png │ ├── correlation_00.png │ ├── correlation_1.png │ ├── correlation_10.png │ ├── correlation_2.png │ ├── correlation_20.png │ ├── correlation_2_array.png │ ├── correlation_pow0.png │ ├── correlation_pow1.png │ ├── correlation_pow10.png │ ├── correlation_pow11.png │ ├── correlation_pow12.png │ ├── correlation_pow13.png │ ├── correlation_pow14.png │ ├── correlation_pow15.png │ ├── correlation_pow16.png │ ├── correlation_pow17.png │ ├── correlation_pow18.png │ ├── correlation_pow19.png │ ├── correlation_pow2.png │ ├── correlation_pow3.png │ ├── correlation_pow4.png │ ├── correlation_pow5.png │ ├── correlation_pow6.png │ ├── correlation_pow7.png │ ├── correlation_pow8.png │ ├── correlation_pow9.png │ ├── data.png │ ├── dict.png │ ├── digit.png │ ├── digits.png │ ├── ecg.png │ ├── ecg_ica.png │ ├── gabor.png │ ├── ica_data.png │ ├── logo_ens_psl_couleur.png │ ├── notes.png │ ├── pca_1.png │ ├── pca_2.png │ ├── pca_data.png │ ├── raw.png │ ├── raw_ica.png │ ├── raw_pca.png │ ├── spect.png │ └── spectrum.png ├── index.html ├── slides.css ├── tree.svg ├── webfont-ubuntu-400-300-100.css └── webfont-ubuntu-mono-400-700-400italic.css ├── 09_database.pdf ├── README.md └── remark.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints 2 | .idea 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Data@PSL 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine learning preparatory week @PSL 2 | 3 | ## Lectures 4 | 5 | 1. [Machine learning: history, application, successes](https://data-psl.github.io/lectures2020/slides/01_machine_learning_successes) 6 | 2. [Introduction to machine learning](https://data-psl.github.io/lectures2020/slides/02_intro_to_machine_learning) 7 | 3. [Supervised machine learning models](https://data-psl.github.io/lectures2020/slides/03_machine_learning_models/) 8 | 4. [Scikit-learn: estimation and pipelines](https://data-psl.github.io/lectures2020/slides/04_scikit_learn/) 9 | 5. [Optimization for linear models](https://data-psl.github.io/lectures2020/slides/05_optimization_linear_models/) 10 | 6. [Optimization for machine learning](https://data-psl.github.io/lectures2020/slides/06_optimization_general/) 11 | 7. [Deep learning: convolutional neural networks](https://data-psl.github.io/lectures2020/slides/07_deep_learning/) 12 | 8. [Unsupervised learning](https://data-psl.github.io/lectures2020/slides/08_unsupervised_learning/) 13 | 9. [Introduction to Relational Database Management Systems](https://data-psl.github.io/lectures2020/slides/09_database.pdf) 14 | [(video)](https://www.youtube.com/watch?v=GLeBTLoXF7Y) 15 | 16 | ## Practical works 17 | 18 | Links open Colab notebooks. You may also clone this repository and work locally. 19 | 20 | 1. Monday: [Python basics](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/01_python_basics.ipynb) 21 | 2. Tuesday: [Practice of Scikit-learn](https://github.com/data-psl/lectures2020/tree/master/notebooks/02_sklearn) 22 | 3. Wednesday: [Optimization](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/03_optimization.ipynb) 23 | 4. Thursday: [Classification with PyTorch and GPUs](https://github.com/data-psl/lectures2020/tree/master/notebooks/04_pytorch) 24 | 5. Friday: [Databases in practice with PostgreSQL and Python](https://data-psl.github.io/lectures2020/notebooks/05_sql.pdf), [Solutions](https://github.com/data-psl/lectures2020/tree/master/notebooks/05_sql_solutions.zip) 25 | 26 | ## Teachers 27 | 28 | * [Pierre Ablin](https://pierreablin.com) (ENS, DMA) 29 | * [Mathieu Blondel](https://mblondel.org) (Google Brain) 30 | * [Arthur Mensch](https://amensch.fr) (ENS, DMA) 31 | * [Pierre Senellart](https://pierre.senellart.com) (ENS, DI) 32 | 33 | 34 | ## Acknowledgements 35 | 36 | Some material of this course was borrowed and adapted: 37 | * The slides from ["Deep learning: convolutional neural networks"](https://data-psl.github.io/lectures2020/slides/07_deep_learning/) are adapted from 38 | Charles Ollion and Olivier Grisel's [advanced course on deep learning](!https://github.com/m2dsupsdlclass/lectures-labs) (released under the 39 | [CC-By 4.0 license](https://creativecommons.org/licenses/by/4.0/legalcode)). 40 | * The first notebooks of the scikit-learn tutorial are taken from Jake Van der Plas [tutorial](https://github.com/jakevdp/sklearn_tutorial). 41 | 42 | ## License 43 | All the code in this repository is made available under the MIT license unless otherwise noted. 44 | 45 | The slides are published under the terms of the [CC-By 4.0 license](https://creativecommons.org/licenses/by/4.0/legalcode). 46 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "{{ site.theme }}"; 5 | 6 | #header_wrap { 7 | display: none; 8 | } 9 | -------------------------------------------------------------------------------- /notebooks/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/.DS_Store -------------------------------------------------------------------------------- /notebooks/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | 140 | 02_sklearn/lectures2020 141 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Jake Vanderplas, modified 2020 by Arthur Mensch 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of sklearn_tutorial nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/README.md: -------------------------------------------------------------------------------- 1 | # Scikit-learn with Python 2 | 3 | This tutorial is an adapted version of *Jake VanderPlas* [tutorial](https://github.com/jakevdp/sklearn_tutorial.git). 4 | 5 | This folder contains notebooks and other files associated with this 6 | [Scikit-learn](http://scikit-learn.org) tutorial. 7 | 8 | The following notebooks should be ran in order in Colab/our your Python install 9 | 10 | Beware that you need to save a copy of your notebook after opening to be able to edit it ! 11 | 12 | - [01 Preliminaries](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/01-Preliminaries.ipynb) 13 | - [02.1 Machine learning intro](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/02.1-Machine-Learning-Intro.ipynb) 14 | - [02.2 Basic Principles](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/02.2-Basic-Principles.ipynb) 15 | - [03.1 Classification/SVMs](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/03.1-Classification-SVMs.ipynb) 16 | - [03.2 Regression with random forests](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/03.2-Regression-Forests.ipynb) 17 | - [04.1 Dimensionality reduction with a PCA](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/04.1-Dimensionality-PCA.ipynb) 18 | - [04.2 Clustering with k-means](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/04.2-Clustering-KMeans.ipynb) 19 | - [04.3 Density and GMM](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/04.3-Density-GMM.ipynb) 20 | - [05 Validation](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/05-Validation.ipynb) 21 | 22 | - [06 Pipeline](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/02_sklearn/06-Pipeline.ipynb) 23 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/URL.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "display_name": "Python 3", 5 | "language": "python", 6 | "name": "python3" 7 | }, 8 | "language_info": { 9 | "codemirror_mode": { 10 | "name": "ipython", 11 | "version": 3 12 | }, 13 | "file_extension": ".py", 14 | "mimetype": "text/x-python", 15 | "name": "python", 16 | "nbconvert_exporter": "python", 17 | "pygments_lexer": "ipython3", 18 | "version": "3.3.5" 19 | }, 20 | "name": "", 21 | "signature": "sha256:5941485b19c03919025faae3887fd7ef842661eae6780930de41597909742c69" 22 | }, 23 | "nbformat": 3, 24 | "nbformat_minor": 0, 25 | "worksheets": [ 26 | { 27 | "cells": [ 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "# Scikit-Learn Tutorial\n", 33 | "\n", 34 | "---\n", 35 | "\n", 36 | "


\n", 37 | "\n", 38 | "# Download all materials here:\n", 39 | "# http://github.com/jakevdp/sklearn_tutorial\n", 40 | "\n", 41 | "





\n", 42 | "\n", 43 | "---" 44 | ] 45 | } 46 | ], 47 | "metadata": {} 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/Untitled.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [] 9 | } 10 | ], 11 | "metadata": { 12 | "kernelspec": { 13 | "display_name": "Python 3", 14 | "language": "python", 15 | "name": "python3" 16 | }, 17 | "language_info": { 18 | "codemirror_mode": { 19 | "name": "ipython", 20 | "version": 3 21 | }, 22 | "file_extension": ".py", 23 | "mimetype": "text/x-python", 24 | "name": "python", 25 | "nbconvert_exporter": "python", 26 | "pygments_lexer": "ipython3", 27 | "version": "3.7.4" 28 | } 29 | }, 30 | "nbformat": 4, 31 | "nbformat_minor": 4 32 | } 33 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/__init__.py: -------------------------------------------------------------------------------- 1 | from .data import * 2 | from .figures import * 3 | 4 | from .sgd_separator import plot_sgd_separator 5 | from .linear_regression import plot_linear_regression 6 | from .helpers import plot_iris_knn 7 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def linear_data_sample(N=40, rseed=0, m=3, b=-2): 5 | rng = np.random.RandomState(rseed) 6 | 7 | x = 10 * rng.rand(N) 8 | dy = m / 2 * (1 + rng.rand(N)) 9 | y = m * x + b + dy * rng.randn(N) 10 | 11 | return (x, y, dy) 12 | 13 | 14 | def linear_data_sample_big_errs(N=40, rseed=0, m=3, b=-2): 15 | rng = np.random.RandomState(rseed) 16 | 17 | x = 10 * rng.rand(N) 18 | dy = m / 2 * (1 + rng.rand(N)) 19 | dy[20:25] *= 10 20 | y = m * x + b + dy * rng.randn(N) 21 | 22 | return (x, y, dy) 23 | 24 | 25 | def sample_light_curve(phased=True): 26 | from astroML.datasets import fetch_LINEAR_sample 27 | data = fetch_LINEAR_sample() 28 | t, y, dy = data[18525697].T 29 | 30 | if phased: 31 | P_best = 0.580313015651 32 | t /= P_best 33 | 34 | return (t, y, dy) 35 | 36 | 37 | def sample_light_curve_2(phased=True): 38 | from astroML.datasets import fetch_LINEAR_sample 39 | data = fetch_LINEAR_sample() 40 | t, y, dy = data[10022663].T 41 | 42 | if phased: 43 | P_best = 0.61596079804 44 | t /= P_best 45 | 46 | return (t, y, dy) 47 | 48 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/helpers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Small helpers for code that is not shown in the notebooks 3 | """ 4 | 5 | from sklearn import neighbors, datasets, linear_model 6 | import pylab as pl 7 | import numpy as np 8 | from matplotlib.colors import ListedColormap 9 | 10 | # Create color maps for 3-class classification problem, as with iris 11 | cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#AAAAFF']) 12 | cmap_bold = ListedColormap(['#FF0000', '#00FF00', '#0000FF']) 13 | 14 | def plot_iris_knn(): 15 | iris = datasets.load_iris() 16 | X = iris.data[:, :2] # we only take the first two features. We could 17 | # avoid this ugly slicing by using a two-dim dataset 18 | y = iris.target 19 | 20 | knn = neighbors.KNeighborsClassifier(n_neighbors=3) 21 | knn.fit(X, y) 22 | 23 | x_min, x_max = X[:, 0].min() - .1, X[:, 0].max() + .1 24 | y_min, y_max = X[:, 1].min() - .1, X[:, 1].max() + .1 25 | xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100), 26 | np.linspace(y_min, y_max, 100)) 27 | Z = knn.predict(np.c_[xx.ravel(), yy.ravel()]) 28 | 29 | # Put the result into a color plot 30 | Z = Z.reshape(xx.shape) 31 | pl.figure() 32 | pl.pcolormesh(xx, yy, Z, cmap=cmap_light) 33 | 34 | # Plot also the training points 35 | pl.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold) 36 | pl.xlabel('sepal length (cm)') 37 | pl.ylabel('sepal width (cm)') 38 | pl.axis('tight') 39 | 40 | 41 | def plot_polynomial_regression(): 42 | rng = np.random.RandomState(0) 43 | x = 2*rng.rand(100) - 1 44 | 45 | f = lambda t: 1.2 * t**2 + .1 * t**3 - .4 * t **5 - .5 * t ** 9 46 | y = f(x) + .4 * rng.normal(size=100) 47 | 48 | x_test = np.linspace(-1, 1, 100) 49 | 50 | pl.figure() 51 | pl.scatter(x, y, s=4) 52 | 53 | X = np.array([x**i for i in range(5)]).T 54 | X_test = np.array([x_test**i for i in range(5)]).T 55 | regr = linear_model.LinearRegression() 56 | regr.fit(X, y) 57 | pl.plot(x_test, regr.predict(X_test), label='4th order') 58 | 59 | X = np.array([x**i for i in range(10)]).T 60 | X_test = np.array([x_test**i for i in range(10)]).T 61 | regr = linear_model.LinearRegression() 62 | regr.fit(X, y) 63 | pl.plot(x_test, regr.predict(X_test), label='9th order') 64 | 65 | pl.legend(loc='best') 66 | pl.axis('tight') 67 | pl.title('Fitting a 4th and a 9th order polynomial') 68 | 69 | pl.figure() 70 | pl.scatter(x, y, s=4) 71 | pl.plot(x_test, f(x_test), label="truth") 72 | pl.axis('tight') 73 | pl.title('Ground truth (9th order polynomial)') 74 | 75 | 76 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/linear_regression.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.linear_model import LinearRegression 4 | 5 | 6 | def plot_linear_regression(): 7 | a = 0.5 8 | b = 1.0 9 | 10 | # x from 0 to 10 11 | x = 30 * np.random.random(20) 12 | 13 | # y = a*x + b with noise 14 | y = a * x + b + np.random.normal(size=x.shape) 15 | 16 | # create a linear regression classifier 17 | clf = LinearRegression() 18 | clf.fit(x[:, None], y) 19 | 20 | # predict y from the data 21 | x_new = np.linspace(0, 30, 100) 22 | y_new = clf.predict(x_new[:, None]) 23 | 24 | # plot the results 25 | ax = plt.axes() 26 | ax.scatter(x, y) 27 | ax.plot(x_new, y_new) 28 | 29 | ax.set_xlabel('x') 30 | ax.set_ylabel('y') 31 | 32 | ax.axis('tight') 33 | 34 | 35 | if __name__ == '__main__': 36 | plot_linear_regression() 37 | plt.show() 38 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/fig_code/sgd_separator.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.linear_model import SGDClassifier 4 | from sklearn.datasets.samples_generator import make_blobs 5 | 6 | def plot_sgd_separator(): 7 | # we create 50 separable points 8 | X, Y = make_blobs(n_samples=50, centers=2, 9 | random_state=0, cluster_std=0.60) 10 | 11 | # fit the model 12 | clf = SGDClassifier(loss="hinge", alpha=0.01, 13 | max_iter=200, fit_intercept=True) 14 | clf.fit(X, Y) 15 | 16 | # plot the line, the points, and the nearest vectors to the plane 17 | xx = np.linspace(-1, 5, 10) 18 | yy = np.linspace(-1, 5, 10) 19 | 20 | X1, X2 = np.meshgrid(xx, yy) 21 | Z = np.empty(X1.shape) 22 | for (i, j), val in np.ndenumerate(X1): 23 | x1 = val 24 | x2 = X2[i, j] 25 | p = clf.decision_function(np.array([x1, x2]).reshape(1, -1)) 26 | Z[i, j] = p[0] 27 | levels = [-1.0, 0.0, 1.0] 28 | linestyles = ['dashed', 'solid', 'dashed'] 29 | colors = 'k' 30 | 31 | ax = plt.axes() 32 | ax.contour(X1, X2, Z, levels, colors=colors, linestyles=linestyles) 33 | ax.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired) 34 | 35 | ax.axis('tight') 36 | 37 | 38 | if __name__ == '__main__': 39 | plot_sgd_separator() 40 | plt.show() 41 | -------------------------------------------------------------------------------- /notebooks/02_sklearn/images/data-layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/02_sklearn/images/data-layout.png -------------------------------------------------------------------------------- /notebooks/02_sklearn/images/iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/02_sklearn/images/iris_setosa.jpg -------------------------------------------------------------------------------- /notebooks/02_sklearn/images/iris_versicolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/02_sklearn/images/iris_versicolor.jpg -------------------------------------------------------------------------------- /notebooks/02_sklearn/images/iris_virginica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/02_sklearn/images/iris_virginica.jpg -------------------------------------------------------------------------------- /notebooks/02_sklearn/solutions/06-Pipeline-1.py: -------------------------------------------------------------------------------- 1 | # Define a pipeline to search for the best combination of PCA truncation 2 | # and classifier regularization. 3 | pca = PCA() 4 | # set the tolerance to a large value to make the example faster 5 | logistic = LogisticRegression(max_iter=10000, tol=0.1) 6 | pipe = Pipeline(steps=[('pca', pca), ('logistic', logistic)]) -------------------------------------------------------------------------------- /notebooks/05_sql.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/05_sql.pdf -------------------------------------------------------------------------------- /notebooks/05_sql_solutions.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/notebooks/05_sql_solutions.zip -------------------------------------------------------------------------------- /notebooks/README.md: -------------------------------------------------------------------------------- 1 | ## Practical works 2 | 3 | Links open Colab notebooks. You may also clone this repository and work locally. 4 | 5 | 1. Monday: [Python basics](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/01_python_basics.ipynb) 6 | 2. Tuesday: [Practice of Scikit-learn](https://github.com/data-psl/lectures2020/tree/master/notebooks/02_sklearn) 7 | 3. Wednesday: [Optimization](https://colab.research.google.com/github/data-psl/lectures2020/blob/master/notebooks/03_optimization.ipynb) 8 | 4. Thursday: [Classification with PyTorch and GPUs](https://github.com/data-psl/lectures2020/tree/master/notebooks/02_sklearn) 9 | 5. Friday: [Databases in practice with PostgreSQL and Python](https://github.com/data-psl/lectures2020/tree/master/notebooks/05_sql.pdf), [Solutions](https://github.com/data-psl/lectures2020/tree/master/notebooks/05_sql_solutions.zip) 10 | -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/WaveNet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/WaveNet.gif -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/ada_lovelace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/ada_lovelace.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/alan_turing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/alan_turing.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/autonomous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/autonomous.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/behavior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/behavior.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/brain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/brain.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/cambridge_analytica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/cambridge_analytica.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/china.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/china.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/clearview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/clearview.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/criteo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/criteo.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/dermato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/dermato.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/edsger_dijkstra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/edsger_dijkstra.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/faceid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/faceid.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/frameworks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/frameworks.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/games.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/games.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/generator.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/gpt3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/gpt3.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/gpu_tpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/gpu_tpu.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/images.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/intelligence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/intelligence.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/latent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/latent.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/learning1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/learning1.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/learning2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/learning2.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/learning3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/learning3.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/machine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/machine.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/machine_learning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/machine_learning.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/minsky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/minsky.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/neural_networks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/neural_networks.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/neuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/neuron.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/nlp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/nlp.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/nlp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/nlp2.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/nlp_vision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/nlp_vision.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/nvidia_celeb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/nvidia_celeb.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/papers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/papers.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/revenues.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/revenues.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/rl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/rl.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/rosenblatt.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/rosenblatt.jpeg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/shannon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/shannon.jpg -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/speech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/speech.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/text.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/vision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/vision.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/vision2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/vision2.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/vision_translation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/vision_translation.png -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/images/von_neumann.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/01_machine_learning_successes/images/von_neumann.gif -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | clear: both; 14 | } 15 | h1 { 16 | margin-top: 0.5em; 17 | } 18 | h2 { 19 | font-size: 140%; 20 | line-height: 150%; 21 | } 22 | h3 { 23 | font-size: 120%; 24 | line-height: 140%; 25 | } 26 | h2, h3, h4, h5, h6 { 27 | font-weight: normal; 28 | } 29 | 30 | 31 | li { 32 | font-size: 120%; 33 | line-height: 160%; 34 | } 35 | 36 | p { 37 | font-size: 120%; 38 | line-height: 140%; 39 | } 40 | 41 | .singleimg .middlebelowheader { 42 | text-align: center; 43 | } 44 | 45 | .singleimg img { 46 | max-width: 90%; 47 | max-height: 600px; 48 | /*border: 2px solid #ddd;*/ 49 | } 50 | table { 51 | margin: 0 auto 0.8em; 52 | border-collapse: collapse; 53 | } 54 | td, th { 55 | border: 1px solid #ddd; 56 | padding: 0.3em 0.5em; 57 | } 58 | 59 | .bgheader h1 { 60 | background-color: rgba(0, 0, 0, 0.9); 61 | opacity: 50%; 62 | padding: 0.5em; 63 | color: white; 64 | border-radius: .5em; 65 | } 66 | .middlebelowheader { 67 | /* This fixed size height was found to work well with the slide 68 | scaling mechanism of remark.js: 69 | */ 70 | height: 500px; 71 | display: table-cell; 72 | vertical-align: middle; 73 | } 74 | .widespace h2 { 75 | line-height: 200%; 76 | } 77 | .big .remark-code { 78 | font-size: 200%; 79 | } 80 | .remark-code, .remark-inline-code { 81 | font-family: 'Ubuntu Mono'; 82 | } 83 | 84 | .medium .remark-code { 85 | font-size: 120%; 86 | } 87 | 88 | .mmedium .remark-code { 89 | font-size: 99%; 90 | } 91 | 92 | .affiliations img { 93 | height: 44px; 94 | margin: 2em; 95 | } 96 | 97 | .hidden { 98 | visibility: hidden; 99 | } 100 | 101 | .small { 102 | font-size: 90%; 103 | } 104 | 105 | .credits { 106 | font-style: italic; 107 | font-size: 70%; 108 | } 109 | 110 | .bunchoflogos img { 111 | max-height: 100px; 112 | padding: 1em; 113 | } 114 | 115 | .bunchoflogos p { 116 | text-align: center; 117 | width: 750px; 118 | } 119 | 120 | a:visited { 121 | color: blue; 122 | } 123 | -------------------------------------------------------------------------------- /slides/01_machine_learning_successes/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/README.md: -------------------------------------------------------------------------------- 1 | This directory contains didactic figures and scripts that generate them. 2 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/bagging0.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 89 | 90 | 91 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/bagging0_cross.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 110 | 111 | 112 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/boosting0.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 89 | 90 | 91 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/boosting_trees1.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/cross_validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/cross_validation.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/inference-phase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/inference-phase.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/lin_reg_2_points.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 102 | 103 | 104 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/logistic_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/logistic_curve.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/plot_iris_visualization.py: -------------------------------------------------------------------------------- 1 | """ 2 | Some simple visualizations on the iris data. 3 | """ 4 | 5 | import numpy as np 6 | from sklearn import datasets 7 | from matplotlib import pyplot as plt 8 | import style_figs 9 | 10 | iris = datasets.load_iris() 11 | 12 | # Plot the histograms of each class for each feature 13 | 14 | 15 | X = iris.data 16 | y = iris.target 17 | for x, feature_name in zip(X.T, iris.feature_names): 18 | plt.figure(figsize=(2.5, 2)) 19 | patches = list() 20 | for this_y, target_name in enumerate(iris.target_names): 21 | patch = plt.hist(x[y == this_y], 22 | bins=np.linspace(x.min(), x.max(), 20), 23 | label=target_name) 24 | patches.append(patch[-1][0]) 25 | style_figs.light_axis() 26 | feature_name = feature_name.replace(' ', '_') 27 | feature_name = feature_name.replace('(', '') 28 | feature_name = feature_name.replace(')', '') 29 | plt.savefig('iris_{}_hist.svg'.format(feature_name)) 30 | 31 | plt.figure(figsize=(6, .25)) 32 | plt.legend(patches, iris.target_names, ncol=3, loc=(0, -.37), 33 | borderaxespad=0) 34 | style_figs.no_axis() 35 | plt.savefig('legend_irises.svg') 36 | 37 | 38 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/plot_splines.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple example of overfit with splines 3 | """ 4 | import numpy as np 5 | from matplotlib import pyplot as plt 6 | import style_figs 7 | 8 | from sklearn import datasets, linear_model 9 | 10 | # Load the diabetes dataset 11 | diabetes = datasets.load_diabetes() 12 | 13 | 14 | # Use only one feature 15 | diabetes_X = diabetes.data[:, np.newaxis] 16 | diabetes_X_temp = diabetes_X[:, :, 2] 17 | 18 | # Split the data into training/testing sets 19 | diabetes_X_train = diabetes_X_temp[:-200:3] 20 | diabetes_X_test = diabetes_X_temp[-200:].T 21 | 22 | # Split the targets into training/testing sets 23 | diabetes_y_train = diabetes.target[:-200:3] 24 | diabetes_y_test = diabetes.target[-200:] 25 | 26 | # Sort the data and remove duplicates (for interpolation) 27 | order = np.argsort(diabetes_X_train.ravel()) 28 | X_train = diabetes_X_train.ravel()[order] 29 | y_train = diabetes_y_train[order] 30 | # Avoid duplicates 31 | y_train_ = list() 32 | for this_x in np.unique(X_train): 33 | y_train_.append(np.mean(y_train[X_train == this_x])) 34 | X_train = np.unique(X_train) 35 | 36 | y_train = np.array(y_train_) 37 | 38 | # Create linear regression object 39 | regr = linear_model.LinearRegression() 40 | 41 | # Train the model using the training sets 42 | regr.fit(X_train.reshape((-1, 1)), y_train) 43 | 44 | 45 | plt.figure(1, figsize=(.8*4, .8*3), facecolor='none') 46 | # Plot with test data 47 | plt.clf() 48 | ax = plt.axes([.1, .1, .9, .9]) 49 | 50 | plt.scatter(X_train, y_train, color='k', s=9) 51 | 52 | plt.plot([-.08, .12], regr.predict([[-.08, ], [.12, ]]), 53 | linewidth=3) 54 | 55 | plt.axis('tight') 56 | ymin, ymax = plt.ylim() 57 | style_figs.light_axis() 58 | plt.ylabel('y', size=16, weight=600) 59 | plt.xlabel('x', size=16, weight=600) 60 | 61 | plt.savefig('ols_simple.svg', facecolor='none', edgecolor='none') 62 | 63 | plt.scatter(diabetes_X_test, diabetes_y_test, color='C1', s=9) 64 | plt.ylim(ymin, ymax) 65 | plt.xlim(-.08, .12) 66 | 67 | plt.savefig('ols_test.svg', facecolor='none', edgecolor='none') 68 | 69 | 70 | # Plot cubic splines 71 | plt.clf() 72 | ax = plt.axes([.1, .1, .9, .9]) 73 | 74 | from scipy import interpolate 75 | f = interpolate.interp1d(X_train, y_train, 76 | kind="quadratic", 77 | bounds_error=False, fill_value="extrapolate") 78 | plt.scatter(X_train, y_train, color='k', s=9, zorder=20) 79 | x_spline = np.linspace(-.08, .12, 600) 80 | y_spline = f(x_spline) 81 | plt.plot(x_spline, y_spline, linewidth=3) 82 | 83 | plt.axis('tight') 84 | plt.xlim(-.08, .12) 85 | plt.ylim(ymin, ymax) 86 | 87 | style_figs.light_axis() 88 | 89 | plt.ylabel('y', size=16, weight=600) 90 | plt.xlabel('x', size=16, weight=600) 91 | 92 | 93 | plt.savefig('splines_cubic.svg', facecolor='none', edgecolor='none') 94 | 95 | 96 | plt.scatter(diabetes_X_test, diabetes_y_test, color='C1', s=9) 97 | plt.savefig('splines_test.svg', facecolor='none', edgecolor='none') 98 | 99 | plt.show() 100 | 101 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/style_figs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple styling used for matplotlib figures 3 | """ 4 | 5 | from matplotlib import pyplot as plt 6 | 7 | # Configuration settings to help visibility on small screen / prints 8 | plt.rcParams['xtick.labelsize'] = 20 9 | plt.rcParams['ytick.labelsize'] = 20 10 | plt.rcParams['figure.titlesize'] = 15 11 | plt.rcParams['font.size'] = 20 12 | plt.rcParams['axes.labelsize'] = 20 13 | plt.rcParams['axes.facecolor'] = 'none' 14 | plt.rcParams['legend.fontsize'] = 18 15 | plt.rcParams['lines.linewidth'] = 3 16 | plt.rcParams['figure.figsize'] = [.8 * 6.4, .8 * 4.8] 17 | plt.rcParams['legend.frameon'] = False 18 | plt.rcParams['legend.columnspacing'] = 1.8 19 | plt.rcParams['legend.handlelength'] = 1.5 20 | plt.rcParams['legend.handletextpad'] = 0.5 21 | 22 | # Utility functions 23 | def light_axis(): 24 | "Hide the top and right spines" 25 | ax = plt.gca() 26 | for s in ('top', 'right'): 27 | ax.spines[s].set_visible(False) 28 | plt.xticks(()) 29 | plt.yticks(()) 30 | plt.subplots_adjust(left=.01, bottom=.01, top=.99, right=.99) 31 | 32 | def no_axis(): 33 | plt.axis('off') 34 | plt.subplots_adjust(left=.0, bottom=.0, top=1, right=1) 35 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/supervised.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/supervised.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/training-phase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/training-phase.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/unsupervised.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/unsupervised.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/figures/workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/figures/workflow.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/iris_setosa.jpg -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/iris_versicolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/iris_versicolor.jpg -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/iris_virginica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/iris_virginica.jpg -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | } 14 | h1 { 15 | margin-top: 0.5em; 16 | } 17 | h2 { 18 | font-size: 140%; 19 | line-height: 150%; 20 | } 21 | h3 { 22 | font-size: 120%; 23 | line-height: 140%; 24 | } 25 | h2, h3, h4, h5, h6 { 26 | font-weight: normal; 27 | } 28 | 29 | 30 | li { 31 | font-size: 120%; 32 | line-height: 160%; 33 | } 34 | 35 | p { 36 | font-size: 120%; 37 | line-height: 140%; 38 | } 39 | 40 | .singleimg .middlebelowheader { 41 | text-align: center; 42 | } 43 | 44 | .singleimg img { 45 | max-width: 90%; 46 | max-height: 600px; 47 | /*border: 2px solid #ddd;*/ 48 | } 49 | table { 50 | margin: 0 auto 0.8em; 51 | border-collapse: collapse; 52 | } 53 | td, th { 54 | border: 1px solid #ddd; 55 | padding: 0.3em 0.5em; 56 | } 57 | 58 | .bgheader h1 { 59 | background-color: rgba(0, 0, 0, 0.9); 60 | opacity: 50%; 61 | padding: 0.5em; 62 | color: white; 63 | border-radius: .5em; 64 | } 65 | .middlebelowheader { 66 | /* This fixed size height was found to work well with the slide 67 | scaling mechanism of remark.js: 68 | */ 69 | height: 500px; 70 | display: table-cell; 71 | vertical-align: middle; 72 | } 73 | .widespace h2 { 74 | line-height: 200%; 75 | } 76 | .big .remark-code { 77 | font-size: 200%; 78 | } 79 | .remark-code, .remark-inline-code { 80 | font-family: 'Ubuntu Mono'; 81 | } 82 | 83 | .medium .remark-code { 84 | font-size: 120%; 85 | } 86 | 87 | .mmedium .remark-code { 88 | font-size: 99%; 89 | } 90 | 91 | .affiliations img { 92 | height: 44px; 93 | margin: 2em; 94 | } 95 | 96 | .hidden { 97 | visibility: hidden; 98 | } 99 | 100 | .small { 101 | font-size: 90%; 102 | } 103 | 104 | .credits { 105 | font-style: italic; 106 | font-size: 70%; 107 | } 108 | 109 | .bunchoflogos img { 110 | max-height: 100px; 111 | padding: 1em; 112 | } 113 | 114 | .bunchoflogos p { 115 | text-align: center; 116 | width: 750px; 117 | } 118 | 119 | a:visited { 120 | color: blue; 121 | } 122 | -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_001.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_003.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_004.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_bias_variance_006.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_iris_knn_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_iris_knn_001.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_iris_scatter_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_iris_scatter_001.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_polynomial_regression_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_polynomial_regression_001.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_polynomial_regression_002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_polynomial_regression_002.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_svm_non_linear_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_svm_non_linear_001.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/sphx_glr_plot_svm_non_linear_002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/02_intro_to_machine_learning/sphx_glr_plot_svm_non_linear_002.png -------------------------------------------------------------------------------- /slides/02_intro_to_machine_learning/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/boston_figs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_boston 3 | import matplotlib.pyplot as plt 4 | from sklearn.ensemble import RandomForestRegressor 5 | from sklearn.kernel_ridge import KernelRidge 6 | from matplotlib import cm 7 | 8 | 9 | s = 10 10 | X, y = load_boston(return_X_y=True) 11 | X = X[:, [0, 5]] 12 | 13 | # print(np.argsort(X[:, 0])) 14 | f, ax = plt.subplots(figsize=(4, 2.2)) 15 | ax.set_xlim(0.01, 90) 16 | ax.set_ylim(4, 51) 17 | ax.set_xscale('log') 18 | x_ = ax.set_xlabel('Crime rate') 19 | y_ = ax.set_ylabel('Target: median price') 20 | 21 | plt.savefig('images/boston_1.png', bbox_extra_artists=[x_, y_], 22 | bbox_inches='tight', dpi=200) 23 | 24 | plt.scatter([X[358, 0]], [y[358]], c='k', s=s, marker='x') 25 | plt.savefig('images/boston_2.png', bbox_extra_artists=[x_, y_], 26 | bbox_inches='tight', dpi=200) 27 | 28 | 29 | plt.scatter(X[:, 0], y, c='k', s=s, marker='x') 30 | plt.savefig('images/boston_3.png', bbox_extra_artists=[x_, y_], 31 | bbox_inches='tight', dpi=200) 32 | 33 | 34 | rf = RandomForestRegressor(max_depth=3).fit(X[:, 0].reshape(-1, 1), y) 35 | xx = np.logspace(-2, 2) 36 | plt.plot(xx, rf.predict(xx.reshape(-1, 1)), linewidth=3, c='red', 37 | label='prediction') 38 | plt.legend() 39 | plt.savefig('images/boston_31.png', bbox_extra_artists=[x_, y_], 40 | bbox_inches='tight', dpi=200) 41 | plt.close('all') 42 | 43 | f, ax = plt.subplots(figsize=(4, 2.2)) 44 | ax.set_xlim(.01, 90) 45 | ax.set_ylim(3, 9) 46 | ax.set_xscale('log') 47 | x_ = ax.set_xlabel('Crime rate') 48 | y_ = ax.set_ylabel('Average number of rooms') 49 | sc = plt.scatter(X[:, 0], X[:, 1], c=y, s=s, marker='x') 50 | c_ = plt.colorbar(sc) 51 | plt.savefig('images/boston_4.png', bbox_extra_artists=[x_, y_], 52 | bbox_inches='tight', dpi=200) 53 | 54 | 55 | rf = RandomForestRegressor().fit(X, y) 56 | # rf = KernelRidge().fit(X, y) 57 | 58 | xx, yy = np.meshgrid(np.linspace(0, 90), 59 | np.linspace(3, 9)) 60 | Z = rf.predict(np.c_[xx.ravel(), yy.ravel()]) 61 | Z = Z.reshape(xx.shape) 62 | plt.contourf(xx, yy, Z, levels=2, alpha=0.5) 63 | plt.savefig('images/boston_5.png', bbox_extra_artists=[x_, y_], 64 | bbox_inches='tight', dpi=200) 65 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/decision_trees.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.datasets import load_iris 4 | 5 | 6 | s=20 7 | 8 | X, y = load_iris(return_X_y=True) 9 | X = X[:, [2, 3]] 10 | 11 | f, ax = plt.subplots(figsize=(4, 2.2)) 12 | ax.set_xlim(0, 7) 13 | ax.set_ylim(0, 2.7) 14 | 15 | x_ = ax.set_xlabel('Petal length') 16 | y_ = ax.set_ylabel('Petal width') 17 | 18 | for i, name in enumerate(['Setosa', 'Versicolor', 'Virginica']): 19 | loc = np.where(y == i)[0] 20 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 21 | plt.legend(loc='upper left') 22 | 23 | ax.vlines(2.5, 0, 2.7, color='k') 24 | plt.savefig('images/decision_trees.png', bbox_extra_artists=[x_, y_], 25 | bbox_inches='tight', dpi=200) 26 | 27 | 28 | ax.fill([0, 0, 2.5, 2.5], [0, 2.7, 2.7, 0], c='blue', alpha=.3) 29 | plt.savefig('images/decision_trees1.png', bbox_extra_artists=[x_, y_], 30 | bbox_inches='tight', dpi=200) 31 | 32 | 33 | ax.hlines(1.75, 2.5, 7, color='k') 34 | plt.savefig('images/decision_trees2.png', bbox_extra_artists=[x_, y_], 35 | bbox_inches='tight', dpi=200) 36 | 37 | 38 | ax.fill([2.5, 2.5, 7, 7], [1.75, 2.7, 2.7, 1.75], c='green', alpha=.3) 39 | plt.savefig('images/decision_trees3.png', bbox_extra_artists=[x_, y_], 40 | bbox_inches='tight', dpi=200) 41 | 42 | ax.vlines(4.95, 0, 1.75, color='k') 43 | plt.savefig('images/decision_trees4.png', bbox_extra_artists=[x_, y_], 44 | bbox_inches='tight', dpi=200) 45 | 46 | 47 | ax.fill([2.5, 2.5, 4.95, 4.95], [0, 1.75, 1.75, 0], c='orange', alpha=.3) 48 | plt.savefig('images/decision_trees5.png', bbox_extra_artists=[x_, y_], 49 | bbox_inches='tight', dpi=200) 50 | 51 | 52 | ax.fill([4.95, 4.95, 7, 7], [0, 1.75, 1.75, 0], c='green', alpha=.3) 53 | plt.savefig('images/decision_trees6.png', bbox_extra_artists=[x_, y_], 54 | bbox_inches='tight', dpi=200) 55 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/forest.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.tree import DecisionTreeClassifier 4 | from sklearn.ensemble import RandomForestClassifier 5 | 6 | 7 | def get_xy(n=1000, sigma=.1): 8 | X = np.random.rand(n, 2) 9 | y = np.zeros(n) 10 | y[X[:, 0] + X[:, 1] < 1] = 1 11 | frac = 15 12 | X += sigma * np.random.randn(n, 2) 13 | # y[:n // frac] = np.random.randn(n // frac) > 0 14 | return X, y 15 | 16 | 17 | f, ax = plt.subplots(figsize=(3.5, 3.5)) 18 | xm, xM = 0, 1 19 | ax.set_xlim(xm, xM) 20 | ax.set_ylim(xm, xM) 21 | X, y = get_xy() 22 | s = 3 23 | plt.plot(np.linspace(xm, xM), 1 - np.linspace(xm, xM), c='k', label='true limit') 24 | for i, name in enumerate(['class 1', 'class 2']): 25 | loc = np.where(y == i)[0] 26 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 27 | plt.legend() 28 | ax.set_xticks([]) 29 | ax.set_yticks([]) 30 | plt.savefig('images/trees.png', dpi=200) 31 | 32 | depths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 33 | 34 | for i, depth in enumerate(depths): 35 | tree = DecisionTreeClassifier(max_depth=depth).fit(X, y) 36 | xx, yy = np.meshgrid(np.linspace(xm, xM), 37 | np.linspace(xm, xM)) 38 | 39 | Z = tree.predict(np.c_[xx.ravel(), yy.ravel()]) 40 | Z = Z.reshape(xx.shape) 41 | colors = ['b', 'orange'] 42 | contour = plt.contourf(xx, yy, Z, levels=1, alpha=0.3, colors=colors) 43 | plt.savefig('images/trees_%s.png' % (i+1), dpi=200) 44 | for coll in contour.collections: 45 | coll.remove() 46 | 47 | 48 | 49 | depths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 50 | 51 | for i, depth in enumerate(depths): 52 | tree = RandomForestClassifier(max_depth=depth).fit(X, y) 53 | xx, yy = np.meshgrid(np.linspace(xm, xM), 54 | np.linspace(xm, xM)) 55 | 56 | Z = tree.predict(np.c_[xx.ravel(), yy.ravel()]) 57 | Z = Z.reshape(xx.shape) 58 | colors = ['b', 'orange'] 59 | contour = plt.contourf(xx, yy, Z, levels=1, alpha=0.3, colors=colors) 60 | plt.savefig('images/trees_%s.png' % (i+1 + 10), dpi=200) 61 | for coll in contour.collections: 62 | coll.remove() 63 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_1.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_31.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/boston_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/boston_5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees1.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/decision_trees6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/decision_trees6.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/forest_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/forest_picture.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_1.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_10.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_11.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_12.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_13.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_14.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_15.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_6.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_7.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_8.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/iris_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/iris_9.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/linear_model1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/linear_model1.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/linear_model2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/linear_model2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/linear_model3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/linear_model3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/linear_model4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/linear_model4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_one_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_one_2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_one_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_one_3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_one_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_one_4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_one_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_one_5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_one_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_one_6.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_two_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_two_2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_two_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_two_3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_two_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_two_4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_two_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_two_5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/nn_two_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/nn_two_6.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_1.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_10.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_11.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_12.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_13.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_14.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_15.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_16.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_17.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_18.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_19.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_2.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_20.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_3.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_4.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_5.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_6.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_7.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_8.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/images/trees_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/03_machine_learning_models/images/trees_9.png -------------------------------------------------------------------------------- /slides/03_machine_learning_models/iris_figs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_iris 3 | import matplotlib.pyplot as plt 4 | from sklearn.ensemble import RandomForestClassifier 5 | from matplotlib import cm 6 | 7 | s=20 8 | X, y = load_iris(return_X_y=True) 9 | X = X[:, [2, 3]] 10 | 11 | f, ax = plt.subplots(figsize=(4, 2.2)) 12 | ax.set_xlim(0, 7) 13 | ax.set_ylim(0, 2.7) 14 | 15 | x_ = ax.set_xlabel('Petal length') 16 | y_ = ax.set_ylabel('Petal width') 17 | 18 | plt.savefig('images/iris_1.png', bbox_extra_artists=[x_, y_], 19 | bbox_inches='tight', dpi=200) 20 | 21 | plt.scatter([X[0, 0]], [X[0, 1]], c='k', s=s) 22 | plt.savefig('images/iris_2.png', bbox_extra_artists=[x_, y_], 23 | bbox_inches='tight', dpi=200) 24 | 25 | plt.scatter([X[51, 0]], [X[51, 1]], c='k', s=s) 26 | plt.savefig('images/iris_3.png', bbox_extra_artists=[x_, y_], 27 | bbox_inches='tight', dpi=200) 28 | 29 | 30 | plt.scatter(X[:, 0], X[:, 1], c='k', s=s) 31 | plt.savefig('images/iris_4.png', bbox_extra_artists=[x_, y_], 32 | bbox_inches='tight', dpi=200) 33 | 34 | for i, name in enumerate(['Setosa', 'Versicolor', 'Virginica']): 35 | loc = np.where(y == i)[0] 36 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 37 | plt.legend() 38 | plt.savefig('images/iris_5.png', bbox_extra_artists=[x_, y_], 39 | bbox_inches='tight', dpi=200) 40 | 41 | 42 | rf = RandomForestClassifier().fit(X, y) 43 | 44 | xc = [1, .5] 45 | x = np.array([[xc[0], xc[1]]]) 46 | 47 | 48 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 49 | plt.savefig('images/iris_6.png', bbox_extra_artists=[x_, y_], 50 | bbox_inches='tight', dpi=200) 51 | 52 | plt.scatter([xc[0]], [xc[1]], c='blue', marker='x', s=4*s) 53 | plt.savefig('images/iris_7.png', bbox_extra_artists=[x_, y_], 54 | bbox_inches='tight', dpi=200) 55 | 56 | 57 | xc = [4, 1.2] 58 | x = np.array([[xc[0], xc[1]]]) 59 | 60 | 61 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 62 | plt.savefig('images/iris_8.png', bbox_extra_artists=[x_, y_], 63 | bbox_inches='tight', dpi=200) 64 | 65 | plt.scatter([xc[0]], [xc[1]], c='orange', marker='x', s=4*s) 66 | plt.savefig('images/iris_9.png', bbox_extra_artists=[x_, y_], 67 | bbox_inches='tight', dpi=200) 68 | 69 | 70 | 71 | xc = [5, 2.2] 72 | x = np.array([[xc[0], xc[1]]]) 73 | 74 | 75 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 76 | plt.savefig('images/iris_10.png', bbox_extra_artists=[x_, y_], 77 | bbox_inches='tight', dpi=200) 78 | 79 | plt.scatter([xc[0]], [xc[1]], c='green', marker='x', s=4*s) 80 | plt.savefig('images/iris_11.png', bbox_extra_artists=[x_, y_], 81 | bbox_inches='tight', dpi=200) 82 | 83 | 84 | xc = [2.5, .8] 85 | x = np.array([[xc[0], xc[1]]]) 86 | 87 | 88 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 89 | plt.savefig('images/iris_12.png', bbox_extra_artists=[x_, y_], 90 | bbox_inches='tight', dpi=200) 91 | 92 | 93 | xc = [4.9, 1.6] 94 | x = np.array([[xc[0], xc[1]]]) 95 | 96 | 97 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 98 | plt.savefig('images/iris_13.png', bbox_extra_artists=[x_, y_], 99 | bbox_inches='tight', dpi=200) 100 | 101 | 102 | xc = [6, .2] 103 | x = np.array([[xc[0], xc[1]]]) 104 | 105 | 106 | plt.scatter([xc[0]], [xc[1]], c='k', marker='x', s=4*s) 107 | plt.savefig('images/iris_14.png', bbox_extra_artists=[x_, y_], 108 | bbox_inches='tight', dpi=200) 109 | 110 | 111 | rf = RandomForestClassifier().fit(X, y) 112 | xx, yy = np.meshgrid(np.linspace(0, 7), 113 | np.linspace(0, 2.7)) 114 | Z = rf.predict(np.c_[xx.ravel(), yy.ravel()]) 115 | Z = Z.reshape(xx.shape) 116 | colors = ['b', 'orange', 'green'] 117 | plt.contourf(xx, yy, Z, levels=2, alpha=0.3, colors=colors) 118 | plt.savefig('images/iris_15.png', bbox_extra_artists=[x_, y_], 119 | bbox_inches='tight', dpi=200) 120 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/linear_models.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_iris 3 | import matplotlib.pyplot as plt 4 | from sklearn.linear_model import LogisticRegression, LinearRegression 5 | from sklearn.datasets import make_regression 6 | from sklearn.model_selection import train_test_split 7 | from matplotlib import cm 8 | 9 | s=20 10 | X, y = load_iris(return_X_y=True) 11 | X = X[:, [2, 3]][50:] 12 | y = y[50:] - 1 13 | 14 | f, ax = plt.subplots(figsize=(4, 2.2)) 15 | ax.set_xlim(2.5, 7) 16 | ax.set_ylim(0.7, 2.7) 17 | 18 | x_ = ax.set_xlabel('Petal length') 19 | y_ = ax.set_ylabel('Petal width') 20 | 21 | 22 | for i, name in enumerate(['Versicolor', 'Virginica']): 23 | loc = np.where(y == i)[0] 24 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 25 | plt.legend(loc='upper left') 26 | plt.savefig('images/linear_model1.png', bbox_extra_artists=[x_, y_], 27 | bbox_inches='tight', dpi=200) 28 | 29 | 30 | lr = LogisticRegression().fit(X, y) 31 | 32 | c = lr.coef_[0] 33 | b = lr.intercept_ 34 | 35 | print(c, b) 36 | x = np.linspace(2.5, 7) 37 | pred = (- c[0] * x - b) / c[1] 38 | 39 | plt.plot(x, pred, c='k', label='limit', linewidth=3) 40 | plt.legend(loc='upper left') 41 | plt.savefig('images/linear_model2.png', bbox_extra_artists=[x_, y_], 42 | bbox_inches='tight', dpi=200) 43 | 44 | xx, yy = np.meshgrid(np.linspace(2.5, 7), 45 | np.linspace(0.7, 2.7)) 46 | Z = lr.predict(np.c_[xx.ravel(), yy.ravel()]) 47 | Z = Z.reshape(xx.shape) 48 | colors = ['b', 'orange'] 49 | plt.contourf(xx, yy, Z, levels=1, alpha=0.3, colors=colors) 50 | plt.savefig('images/linear_model3.png', bbox_extra_artists=[x_, y_], 51 | bbox_inches='tight', dpi=200) 52 | 53 | 54 | f, ax = plt.subplots(figsize=(3.5, 3.5)) 55 | n = 200 56 | c = np.array([(0, 0), (0, 1), (1, 1), (1, 0)]) 57 | y = [0, 1, 0, 1] 58 | 59 | X = np.concatenate([0.1 * np.random.randn(n, 2) + c_ for c_ in c]) 60 | y = np.concatenate([y_ * np.ones(n) for y_ in y]) 61 | xm, xM = -.5, 1.5 62 | ax.set_xlim(xm, xM) 63 | ax.set_ylim(xm, xM) 64 | s = 3 65 | for i, name in enumerate(['class 1', 'class 2']): 66 | loc = np.where(y == i)[0] 67 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 68 | plt.legend() 69 | ax.set_xticks([]) 70 | ax.set_yticks([]) 71 | 72 | plt.savefig('images/linear_model4.png', dpi=200) 73 | 74 | plt.close('all') 75 | # f, ax = plt.subplots(figsize=(4, 2.2)) 76 | # 77 | # scores = [] 78 | # train = [] 79 | # n_f = 30 80 | # n_features_list = np.arange(1, n_f) 81 | # n_repeat = 100 82 | # for n_features in n_features_list: 83 | # print(n_features) 84 | # sc = [] 85 | # tr = [] 86 | # for i in range(n_repeat): 87 | # X, y = make_regression(n_samples=10, n_features=n_f, n_informative=2) 88 | # X_train, X_test, y_train, y_test = train_test_split(X, y) 89 | # lr = LinearRegression().fit(X_train[:, :n_features], y_train) 90 | # p = lr.predict(X_train[:, :n_features]) 91 | # pred = lr.predict(X_test[:, :n_features]) 92 | # score = np.sqrt(np.mean((y_test - pred) ** 2)) 93 | # sc.append(score) 94 | # tr.append(np.sqrt(np.mean((p - y_train) ** 2))) 95 | # scores.append(np.mean(sc)) 96 | # train.append(np.mean(tr)) 97 | # 98 | # plt.plot(n_features_list, scores) 99 | # plt.plot(n_features_list, train) 100 | # plt.show() 101 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/neural_nets.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | import torch.nn as nn 4 | import torch.optim as optim 5 | from torch.nn import Sequential 6 | import matplotlib.pyplot as plt 7 | 8 | n_hidden = 4 9 | nn1 = Sequential(nn.Linear(2, n_hidden), nn.Tanh(), nn.Linear(n_hidden, 2)) 10 | nn2 = Sequential(nn.Linear(2, n_hidden), nn.Tanh(), 11 | nn.Linear(n_hidden, n_hidden), nn.Tanh(), 12 | nn.Linear(n_hidden, 2)) 13 | 14 | 15 | n = 1000 16 | n_points = 10 17 | t = np.linspace(0, 2 * np.pi, n_points, endpoint=False) 18 | c = np.array([(np.cos(t_), np.sin(t_)) for t_ in t]) 19 | y = np.arange(n_points) % 2 20 | 21 | X = np.concatenate([0.1 * np.random.randn(n, 2) + c_ for c_ in c]) 22 | y = np.concatenate([y_ * np.ones(n) for y_ in y]) 23 | X = torch.tensor(X).float() 24 | y = torch.tensor(y).long() 25 | 26 | f, ax = plt.subplots(figsize=(3.5, 3.5)) 27 | xm, xM = -1.5, 1.5 28 | ax.set_xlim(xm, xM) 29 | ax.set_ylim(xm, xM) 30 | s = 3 31 | for i, name in enumerate(['class 1', 'class 2']): 32 | loc = np.where(y == i)[0] 33 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 34 | plt.legend() 35 | ax.set_xticks([]) 36 | ax.set_yticks([]) 37 | 38 | plt.savefig('images/nn.png', dpi=200) 39 | 40 | for n_hidden in [2, 3, 4, 5, 6]: 41 | nn1 = Sequential(nn.Linear(2, n_hidden), nn.Tanh(), 42 | nn.Linear(n_hidden, 2 * n_hidden), nn.Tanh(), 43 | nn.Linear(2 * n_hidden, 2)) 44 | optimizer = optim.Adam(nn1.parameters(), lr=1e-2) 45 | criterion = nn.CrossEntropyLoss() 46 | for i in range(1001): 47 | optimizer.zero_grad() 48 | pred = nn1(X) 49 | loss = criterion(pred, y) 50 | loss.backward() 51 | optimizer.step() 52 | if i % 100 == 0: 53 | print(loss.item()) 54 | 55 | 56 | f, ax = plt.subplots(figsize=(3.5, 3.5)) 57 | xm, xM = -1.5, 1.5 58 | ax.set_xlim(xm, xM) 59 | ax.set_ylim(xm, xM) 60 | s = 3 61 | for i, name in enumerate(['class 1', 'class 2']): 62 | loc = np.where(y == i)[0] 63 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 64 | plt.legend() 65 | ax.set_xticks([]) 66 | ax.set_yticks([]) 67 | 68 | 69 | 70 | xx, yy = np.meshgrid(np.linspace(-1.5, 1.5), 71 | np.linspace(-1.5, 1.5)) 72 | data = torch.tensor(np.c_[xx.ravel(), yy.ravel()]).float() 73 | op = nn1(data).detach() 74 | z = op.numpy().argmax(axis=1) 75 | Z = z.reshape(xx.shape) 76 | plt.contourf(xx, yy, Z, levels=1, alpha=0.5, colors=['b', 'orange']) 77 | plt.savefig('images/nn_two_%s.png' % n_hidden, dpi=200) 78 | 79 | 80 | for n_hidden in [2, 3, 4, 5, 6]: 81 | nn1 = Sequential(nn.Linear(2, n_hidden), nn.Tanh(), nn.Linear(n_hidden, 2)) 82 | optimizer = optim.Adam(nn1.parameters(), lr=1e-2) 83 | criterion = nn.CrossEntropyLoss() 84 | for i in range(1001): 85 | optimizer.zero_grad() 86 | pred = nn1(X) 87 | loss = criterion(pred, y) 88 | loss.backward() 89 | optimizer.step() 90 | if i % 100 == 0: 91 | print(loss.item()) 92 | 93 | 94 | f, ax = plt.subplots(figsize=(3.5, 3.5)) 95 | xm, xM = -1.5, 1.5 96 | ax.set_xlim(xm, xM) 97 | ax.set_ylim(xm, xM) 98 | s = 3 99 | for i, name in enumerate(['class 1', 'class 2']): 100 | loc = np.where(y == i)[0] 101 | plt.scatter(X[loc, 0], X[loc, 1], s=s, label=name) 102 | plt.legend() 103 | ax.set_xticks([]) 104 | ax.set_yticks([]) 105 | 106 | 107 | 108 | xx, yy = np.meshgrid(np.linspace(-1.5, 1.5), 109 | np.linspace(-1.5, 1.5)) 110 | data = torch.tensor(np.c_[xx.ravel(), yy.ravel()]).float() 111 | op = nn1(data).detach() 112 | z = op.numpy().argmax(axis=1) 113 | Z = z.reshape(xx.shape) 114 | plt.contourf(xx, yy, Z, levels=1, alpha=0.5, colors=['b', 'orange']) 115 | plt.savefig('images/nn_one_%s.png' % n_hidden, dpi=200) 116 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | } 14 | h1 { 15 | margin-top: 0.5em; 16 | } 17 | h2 { 18 | font-size: 140%; 19 | line-height: 150%; 20 | } 21 | h3 { 22 | font-size: 120%; 23 | line-height: 140%; 24 | } 25 | h2, h3, h4, h5, h6 { 26 | font-weight: normal; 27 | } 28 | 29 | 30 | li { 31 | font-size: 120%; 32 | line-height: 160%; 33 | } 34 | 35 | p { 36 | font-size: 120%; 37 | line-height: 140%; 38 | } 39 | 40 | .singleimg .middlebelowheader { 41 | text-align: center; 42 | } 43 | 44 | .singleimg img { 45 | max-width: 90%; 46 | max-height: 600px; 47 | /*border: 2px solid #ddd;*/ 48 | } 49 | table { 50 | margin: 0 auto 0.8em; 51 | border-collapse: collapse; 52 | } 53 | td, th { 54 | border: 1px solid #ddd; 55 | padding: 0.3em 0.5em; 56 | } 57 | 58 | .bgheader h1 { 59 | background-color: rgba(0, 0, 0, 0.9); 60 | opacity: 50%; 61 | padding: 0.5em; 62 | color: white; 63 | border-radius: .5em; 64 | } 65 | .middlebelowheader { 66 | /* This fixed size height was found to work well with the slide 67 | scaling mechanism of remark.js: 68 | */ 69 | height: 500px; 70 | display: table-cell; 71 | vertical-align: middle; 72 | } 73 | .widespace h2 { 74 | line-height: 200%; 75 | } 76 | .big .remark-code { 77 | font-size: 200%; 78 | } 79 | .remark-code, .remark-inline-code { 80 | font-family: 'Ubuntu Mono'; 81 | } 82 | 83 | .medium .remark-code { 84 | font-size: 120%; 85 | } 86 | 87 | .mmedium .remark-code { 88 | font-size: 99%; 89 | } 90 | 91 | .affiliations img { 92 | height: 44px; 93 | margin: 2em; 94 | } 95 | 96 | .hidden { 97 | visibility: hidden; 98 | } 99 | 100 | .small { 101 | font-size: 90%; 102 | } 103 | 104 | .credits { 105 | font-style: italic; 106 | font-size: 70%; 107 | } 108 | 109 | .bunchoflogos img { 110 | max-height: 100px; 111 | padding: 1em; 112 | } 113 | 114 | .bunchoflogos p { 115 | text-align: center; 116 | width: 750px; 117 | } 118 | 119 | a:visited { 120 | color: blue; 121 | } 122 | -------------------------------------------------------------------------------- /slides/03_machine_learning_models/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/04_scikit_learn/drawings/g5387.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/drawings/g5387.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/drawings/transform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/drawings/transform.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/confusion_matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/confusion_matrix.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/matplotlib.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/matplotlib.webp -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/ml_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/ml_map.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/pandas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/pandas.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/images/seaborn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/images/seaborn.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans0.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans1.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans2.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans3.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans_over.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/kmeans_under.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/04_scikit_learn/kmeans_under.png -------------------------------------------------------------------------------- /slides/04_scikit_learn/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | clear: both; 14 | } 15 | h1 { 16 | margin-top: 0.5em; 17 | } 18 | h2 { 19 | font-size: 140%; 20 | line-height: 150%; 21 | } 22 | h3 { 23 | font-size: 120%; 24 | line-height: 140%; 25 | } 26 | h2, h3, h4, h5, h6 { 27 | font-weight: normal; 28 | } 29 | 30 | 31 | li { 32 | font-size: 120%; 33 | line-height: 160%; 34 | } 35 | 36 | li { 37 | font-size: 100%; 38 | } 39 | 40 | p { 41 | font-size: 120%; 42 | line-height: 140%; 43 | } 44 | 45 | .singleimg .middlebelowheader { 46 | text-align: center; 47 | } 48 | 49 | .singleimg img { 50 | max-width: 90%; 51 | max-height: 600px; 52 | /*border: 2px solid #ddd;*/ 53 | } 54 | table { 55 | margin: 0 auto 0.8em; 56 | border-collapse: collapse; 57 | } 58 | td, th { 59 | border: 1px solid #ddd; 60 | padding: 0.3em 0.5em; 61 | } 62 | 63 | .bgheader h1 { 64 | background-color: rgba(0, 0, 0, 0.9); 65 | opacity: 50%; 66 | padding: 0.5em; 67 | color: white; 68 | border-radius: .5em; 69 | } 70 | .middlebelowheader { 71 | /* This fixed size height was found to work well with the slide 72 | scaling mechanism of remark.js: 73 | */ 74 | height: 500px; 75 | display: table-cell; 76 | vertical-align: middle; 77 | } 78 | .widespace h2 { 79 | line-height: 200%; 80 | } 81 | .big .remark-code { 82 | font-size: 200%; 83 | } 84 | .remark-code, .remark-inline-code { 85 | font-family: 'Ubuntu Mono'; 86 | } 87 | 88 | .medium .remark-code { 89 | font-size: 120%; 90 | } 91 | 92 | .mmedium .remark-code { 93 | font-size: 99%; 94 | } 95 | 96 | .affiliations img { 97 | height: 44px; 98 | margin: 2em; 99 | } 100 | 101 | .hidden { 102 | visibility: hidden; 103 | } 104 | 105 | .small { 106 | font-size: 90%; 107 | } 108 | 109 | .credits { 110 | font-style: italic; 111 | font-size: 70%; 112 | } 113 | 114 | .bunchoflogos img { 115 | max-height: 100px; 116 | padding: 1em; 117 | } 118 | 119 | .bunchoflogos p { 120 | text-align: center; 121 | width: 750px; 122 | } 123 | 124 | a:visited { 125 | color: blue; 126 | } 127 | -------------------------------------------------------------------------------- /slides/04_scikit_learn/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/figures/convex_function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/figures/convex_function.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/figures/stationary_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/figures/stationary_point.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/gd_illust.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import make_regression 3 | from sklearn.model_selection import train_test_split 4 | import matplotlib.pyplot as plt 5 | 6 | seed = np.random.randint(0, 1000) 7 | seed = 188 8 | print(seed) 9 | 10 | rng = np.random.RandomState(seed) 11 | X, y = make_regression(n_samples=100, n_features=2, n_informative=2, random_state=rng) 12 | 13 | X += 0.01 * rng.randn(100, 2) 14 | X, X_test, y, y_test = train_test_split(X, y, random_state=rng) 15 | 16 | 17 | n, p = X.shape 18 | 19 | 20 | def loss(w, train=True): 21 | if train: 22 | x = X 23 | y_ = y 24 | else: 25 | x = X_test 26 | y_ = y_test 27 | res = np.dot(x, w.T) - y_[:, None] 28 | return np.mean(res ** 2, axis=0) 29 | 30 | 31 | def gd(n_iter=10, step=.1): 32 | w_list = [] 33 | w = np.zeros(p) 34 | for i in range(n_iter): 35 | w_list.append(w.copy()) 36 | w -= step * np.dot(X.T, X.dot(w) - y) / n 37 | 38 | return np.array(w_list) 39 | 40 | 41 | n_it = 25 42 | w_gd = gd(n_it, .5) 43 | 44 | w_star = np.linalg.pinv(X).dot(y) 45 | 46 | xm, xM = -10, 1.5 * np.abs(w_star[0]) 47 | ym, yM = -5, 1.5 * np.abs(w_star[1]) 48 | f, ax = plt.subplots(figsize=(4, 2.5)) 49 | ax.set_xlim(xm, xM) 50 | ax.set_ylim(ym, yM) 51 | ax.set_yticks([]) 52 | ax.set_xticks([]) 53 | xx, yy = np.meshgrid(np.linspace(xm, xM), 54 | np.linspace(ym, yM)) 55 | Z = loss(np.c_[xx.ravel(), yy.ravel()]) 56 | Z = Z.reshape(xx.shape) 57 | plt.contourf(xx, yy, Z, alpha=0.3) 58 | plt.scatter([0,], [0,], color='red', s=80, 59 | label='init') 60 | plt.scatter([w_star[0]], [w_star[1]], color='k', s=80, 61 | label='solution') 62 | plt.legend() 63 | plt.savefig('images/gd_illust.png', dpi=200) 64 | 65 | label = 'gd' 66 | for i in range(1, 9): 67 | 68 | plt.plot(w_gd[:i + 1, 0], w_gd[:i + 1, 1], color='blue', label=label) 69 | if label is not None: 70 | label = 'gd' 71 | label = None 72 | plt.scatter(w_gd[:i + 1, 0], w_gd[:i + 1, 1], color='blue', s=50, marker='+') 73 | 74 | plt.legend() 75 | plt.savefig('images/gd_illust_%s.png' % i, dpi=200) 76 | 77 | 78 | 79 | gd_train = loss(w_gd) 80 | gd_test = loss(w_gd, False) 81 | f, ax = plt.subplots(figsize=(4, 2.5)) 82 | x_ = plt.xlabel('Number of pass on the dataset') 83 | y_ = plt.ylabel('Error') 84 | l_min = gd_train 85 | plt.plot(gd_train - l_min, color='royalblue', label='gd train', linewidth=2) 86 | 87 | plt.yscale('log') 88 | plt.legend(ncol=1, loc='lower left') 89 | plt.savefig('images/gd_loss.png', bbox_extra_artists=[x_, y_], 90 | bbox_inches='tight', dpi=200) 91 | plt.plot(gd_test - l_min, color='cyan', label='gd test', linewidth=3) 92 | 93 | plt.legend(ncol=2) 94 | plt.savefig('images/gd_loss1.png', bbox_extra_artists=[x_, y_], 95 | bbox_inches='tight', dpi=200) 96 | -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_1.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_2.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_3.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_4.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_5.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_6.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_7.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_illust_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_illust_8.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_loss.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/images/gd_loss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/05_optimization_linear_models/images/gd_loss1.png -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | } 14 | h1 { 15 | margin-top: 0.5em; 16 | } 17 | h2 { 18 | font-size: 140%; 19 | line-height: 150%; 20 | } 21 | h3 { 22 | font-size: 120%; 23 | line-height: 140%; 24 | } 25 | h2, h3, h4, h5, h6 { 26 | font-weight: normal; 27 | } 28 | 29 | 30 | li { 31 | font-size: 120%; 32 | line-height: 160%; 33 | } 34 | 35 | p { 36 | font-size: 120%; 37 | line-height: 140%; 38 | } 39 | 40 | .singleimg .middlebelowheader { 41 | text-align: center; 42 | } 43 | 44 | .singleimg img { 45 | max-width: 90%; 46 | max-height: 600px; 47 | /*border: 2px solid #ddd;*/ 48 | } 49 | table { 50 | margin: 0 auto 0.8em; 51 | border-collapse: collapse; 52 | } 53 | td, th { 54 | border: 1px solid #ddd; 55 | padding: 0.3em 0.5em; 56 | } 57 | 58 | .bgheader h1 { 59 | background-color: rgba(0, 0, 0, 0.9); 60 | opacity: 50%; 61 | padding: 0.5em; 62 | color: white; 63 | border-radius: .5em; 64 | } 65 | .middlebelowheader { 66 | /* This fixed size height was found to work well with the slide 67 | scaling mechanism of remark.js: 68 | */ 69 | height: 500px; 70 | display: table-cell; 71 | vertical-align: middle; 72 | } 73 | .widespace h2 { 74 | line-height: 200%; 75 | } 76 | .big .remark-code { 77 | font-size: 200%; 78 | } 79 | .remark-code, .remark-inline-code { 80 | font-family: 'Ubuntu Mono'; 81 | } 82 | 83 | .medium .remark-code { 84 | font-size: 120%; 85 | } 86 | 87 | .mmedium .remark-code { 88 | font-size: 99%; 89 | } 90 | 91 | .affiliations img { 92 | height: 44px; 93 | margin: 2em; 94 | } 95 | 96 | .hidden { 97 | visibility: hidden; 98 | } 99 | 100 | .small { 101 | font-size: 90%; 102 | } 103 | 104 | .credits { 105 | font-style: italic; 106 | font-size: 70%; 107 | } 108 | 109 | .bunchoflogos img { 110 | max-height: 100px; 111 | padding: 1em; 112 | } 113 | 114 | .bunchoflogos p { 115 | text-align: center; 116 | width: 750px; 117 | } 118 | 119 | a:visited { 120 | color: blue; 121 | } 122 | -------------------------------------------------------------------------------- /slides/05_optimization_linear_models/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/06_optimization_general/images/lbfgs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/lbfgs.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/newton_cv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/newton_cv.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/quadratic.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/quadratic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/quadratic1.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_1.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_2.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_3.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_4.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_5.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_6.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_7.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_illust_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_illust_8.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_loss.png -------------------------------------------------------------------------------- /slides/06_optimization_general/images/sgd_loss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/06_optimization_general/images/sgd_loss1.png -------------------------------------------------------------------------------- /slides/06_optimization_general/lbfgs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numba import njit 3 | from scipy.optimize import fmin_l_bfgs_b 4 | import matplotlib.pyplot as plt 5 | 6 | 7 | 8 | def loss_logreg(x, A, b, lbda): 9 | bAx = b * np.dot(A, x) 10 | return np.mean(np.log1p(np.exp(- bAx))) + lbda * np.dot(x, x) / 2. 11 | 12 | 13 | @njit 14 | def grad_i_logreg(i, x, A, b, lbda): 15 | """Gradient with respect to a sample""" 16 | a_i = A[i] 17 | b_i = b[i] 18 | return - a_i * b_i / (1. + np.exp(b_i * np.dot(a_i, x))) + lbda * x 19 | 20 | 21 | @njit 22 | def grad_logreg(x, A, b, lbda): 23 | """Full gradient""" 24 | g = np.zeros_like(x) 25 | for i in range(n): 26 | g += grad_i_logreg(i, x, A, b, lbda) 27 | return g / n 28 | 29 | 30 | def gd(n_iter): 31 | l_cst = np.linalg.norm(A, ord=2) ** 2 / (4. * n) + lbda 32 | step = 2 / l_cst 33 | l_list = [] 34 | x = np.zeros(p) 35 | for i in range(n_iter): 36 | x -= step * grad_logreg(x, A, b, lbda) 37 | l_list.append(loss_logreg(x, A, b, lbda)) 38 | return l_list 39 | 40 | 41 | class cb(object): 42 | def __init__(self): 43 | self.l_list = [] 44 | 45 | def __call__(self, x): 46 | self.l_list.append(loss_logreg(x, A, b, lbda)) 47 | 48 | 49 | n, p = 1000, 5000 50 | A = np.random.randn(n, p) 51 | b = np.random.randn(n) 52 | lbda = .1 53 | x = np.zeros(p) 54 | 55 | factr=10 56 | f, ax = plt.subplots(figsize=(4, 2)) 57 | c = cb() 58 | _ = fmin_l_bfgs_b(loss_logreg, np.zeros(p), fprime=grad_logreg, callback=c, args=(A, b, lbda), 59 | factr=factr) 60 | 61 | l1 = np.array(c.l_list) 62 | l2 = np.array(gd(len(l1))) 63 | 64 | print(l1) 65 | print(l2) 66 | l_m = min((np.min(l1), np.min(l2))) 67 | plt.plot(l1 - l_m, label='L-BFGS') 68 | plt.plot(l2 - l_m, label='Gradient descent') 69 | x_ = plt.xlabel('Iterations') 70 | y_ = plt.ylabel('Error') 71 | plt.legend() 72 | plt.yscale('log') 73 | plt.savefig('images/lbfgs.png', dpi=200, bbox_inches='tight', 74 | bbox_extra_artists=[x_, y_]) 75 | -------------------------------------------------------------------------------- /slides/06_optimization_general/loss_illust.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import matplotlib.pyplot as plt 4 | 5 | 6 | n_it = 20 7 | 8 | 9 | 10 | train_gd = np.exp(-) 11 | -------------------------------------------------------------------------------- /slides/06_optimization_general/quadratic.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import make_regression 3 | from sklearn.model_selection import train_test_split 4 | import matplotlib.pyplot as plt 5 | 6 | 7 | fontsize = 18 8 | params = { 9 | 'axes.titlesize': fontsize + 4, 10 | 'axes.labelsize': fontsize + 2, 11 | 'font.size': fontsize + 2, 12 | 'legend.fontsize': fontsize + 2, 13 | 'xtick.labelsize': fontsize, 14 | 'ytick.labelsize': fontsize, 15 | 'text.usetex': True} 16 | plt.rcParams.update(params) 17 | 18 | A = np.array([[3, -1], [-1, 1]]) 19 | 20 | x_star = np.array([1, 1]) 21 | 22 | b = - np.dot(A, x_star) 23 | 24 | 25 | def loss(w, train=True): 26 | return .5 * np.sum(w * w.dot(A), axis=1) + w.dot(b) 27 | 28 | 29 | xm, xM = -1, 3 30 | ym, yM = -1, 3 31 | f, ax = plt.subplots(figsize=(4, 2.5)) 32 | ax.set_xlim(xm, xM) 33 | ax.set_ylim(ym, yM) 34 | ax.set_yticks([]) 35 | ax.set_xticks([]) 36 | plt.xlabel(r"$w'_1$") 37 | plt.ylabel(r"$w'_2$") 38 | xx, yy = np.meshgrid(np.linspace(xm, xM), 39 | np.linspace(ym, yM)) 40 | Z = loss(np.c_[xx.ravel(), yy.ravel()]) 41 | Z = Z.reshape(xx.shape) 42 | plt.contourf(xx, yy, Z, alpha=0.5) 43 | plt.scatter([0, ], [0, ], color='k', s=80, 44 | label=r'$w$') 45 | plt.legend() 46 | plt.savefig('images/quadratic.png', dpi=200) 47 | plt.scatter([1, ], [1, ], color='red', s=120, marker='x', 48 | label=r'$\tilde{w}$') 49 | plt.legend() 50 | plt.savefig('images/quadratic1.png', dpi=200) 51 | 52 | 53 | 54 | f, ax = plt.subplots(figsize=(6, 2)) 55 | 56 | t = np.arange(1, 15) 57 | 58 | v1 = np.exp(-t / 2) 59 | v2 = np.exp(-t ** 2 / 10) 60 | 61 | plt.plot(t, v1, label='gradient descent') 62 | plt.plot(t, v2, label="Newton's method") 63 | plt.legend() 64 | x_ = plt.xlabel('iterations') 65 | y_ = plt.ylabel('error') 66 | plt.yscale('log') 67 | plt.savefig('images/newton_cv.png', dpi=200, bbox_extra_artists=[x_, y_], 68 | bbox_inches='tight') 69 | -------------------------------------------------------------------------------- /slides/06_optimization_general/sgd_illust.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import make_regression 3 | from sklearn.model_selection import train_test_split 4 | import matplotlib.pyplot as plt 5 | 6 | seed = np.random.randint(0, 1000) 7 | seed = 188 8 | print(seed) 9 | 10 | rng = np.random.RandomState(seed) 11 | X, y = make_regression(n_samples=100, n_features=2, n_informative=2, random_state=rng) 12 | 13 | X += 0.01 * rng.randn(100, 2) 14 | X, X_test, y, y_test = train_test_split(X, y, random_state=rng) 15 | 16 | 17 | n, p = X.shape 18 | 19 | 20 | def loss(w, train=True): 21 | if train: 22 | x = X 23 | y_ = y 24 | else: 25 | x = X_test 26 | y_ = y_test 27 | res = np.dot(x, w.T) - y_[:, None] 28 | return np.mean(res ** 2, axis=0) 29 | 30 | 31 | def gd(n_iter=10, step=.1): 32 | w_list = [] 33 | w = np.zeros(p) 34 | for i in range(n_iter): 35 | w_list.append(w.copy()) 36 | w -= step * np.dot(X.T, X.dot(w) - y) / n 37 | 38 | return np.array(w_list) 39 | 40 | 41 | def sgd(n_iter=1000, step=.1): 42 | w_list = [] 43 | w = np.zeros(p) 44 | for i in range(n_iter): 45 | idx = i % n 46 | w_list.append(w.copy()) 47 | w -= step * (X[idx].dot(w) - y[idx]) * X[idx] 48 | return np.array(w_list) 49 | 50 | 51 | n_it = 25 52 | w_gd = gd(n_it, .5) 53 | w_sgd = sgd(n_it * n, .02) 54 | 55 | w_star = np.linalg.pinv(X).dot(y) 56 | 57 | xm, xM = -10, 1.5 * np.abs(w_star[0]) 58 | ym, yM = -5, 1.5 * np.abs(w_star[1]) 59 | f, ax = plt.subplots(figsize=(4, 2.5)) 60 | ax.set_xlim(xm, xM) 61 | ax.set_ylim(ym, yM) 62 | ax.set_yticks([]) 63 | ax.set_xticks([]) 64 | xx, yy = np.meshgrid(np.linspace(xm, xM), 65 | np.linspace(ym, yM)) 66 | Z = loss(np.c_[xx.ravel(), yy.ravel()]) 67 | Z = Z.reshape(xx.shape) 68 | plt.contourf(xx, yy, Z, alpha=0.3) 69 | plt.scatter([0,], [0,], color='red', s=80, 70 | label='init') 71 | plt.scatter([w_star[0]], [w_star[1]], color='k', s=80, 72 | label='solution') 73 | plt.legend() 74 | plt.savefig('images/sgd_illust.png', dpi=200) 75 | 76 | label = 'gd' 77 | for i in range(1, 9): 78 | 79 | plt.plot(w_gd[:i + 1, 0], w_gd[:i + 1, 1], color='blue', label=label) 80 | if label is not None: 81 | label = 'sgd' 82 | plt.plot(w_sgd[:(n * i), 0], w_sgd[:(n * i), 1], color='orange', label=label) 83 | label = None 84 | plt.scatter(w_gd[:i + 1, 0], w_gd[:i + 1, 1], color='blue', s=50, marker='+') 85 | plt.scatter(w_sgd[:(n * i):n, 0], w_sgd[:(n * i):n, 1], color='orange', s=50, marker='+') 86 | 87 | plt.legend() 88 | plt.savefig('images/sgd_illust_%s.png' % i, dpi=200) 89 | 90 | 91 | 92 | w_sgd = sgd(n_it * n, .04) 93 | gd_train = loss(w_gd) 94 | gd_test = loss(w_gd, False) 95 | sgd_train = loss(w_sgd)[::20] 96 | sgd_test = loss(w_sgd, False)[::20] 97 | f, ax = plt.subplots(figsize=(4, 2.5)) 98 | x_ = plt.xlabel('Number of pass on the dataset') 99 | y_ = plt.ylabel('Error') 100 | l_min = min((np.min(gd_train), np.min(sgd_train))) 101 | plt.plot(gd_train - l_min, color='royalblue', label='gd train', linewidth=2) 102 | 103 | plt.plot(np.linspace(0, n_it - 1, len(sgd_train)), 104 | sgd_train - l_min, color='red', label='sgd train', linewidth=2) 105 | 106 | plt.yscale('log') 107 | plt.legend(ncol=1, loc='lower left') 108 | plt.savefig('images/sgd_loss.png', bbox_extra_artists=[x_, y_], 109 | bbox_inches='tight', dpi=200) 110 | plt.plot(gd_test - l_min, color='cyan', label='gd test', linewidth=3) 111 | plt.plot(np.linspace(0, n_it - 1, len(sgd_train)), 112 | sgd_test - l_min, color='orange', label='sgd test', 113 | linewidth=3) 114 | 115 | plt.legend(ncol=2) 116 | plt.savefig('images/sgd_loss1.png', bbox_extra_artists=[x_, y_], 117 | bbox_inches='tight', dpi=200) 118 | -------------------------------------------------------------------------------- /slides/06_optimization_general/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | } 14 | h1 { 15 | margin-top: 0.5em; 16 | } 17 | h2 { 18 | font-size: 140%; 19 | line-height: 150%; 20 | } 21 | h3 { 22 | font-size: 120%; 23 | line-height: 140%; 24 | } 25 | h2, h3, h4, h5, h6 { 26 | font-weight: normal; 27 | } 28 | 29 | 30 | li { 31 | font-size: 120%; 32 | line-height: 160%; 33 | } 34 | 35 | p { 36 | font-size: 120%; 37 | line-height: 140%; 38 | } 39 | 40 | .singleimg .middlebelowheader { 41 | text-align: center; 42 | } 43 | 44 | .singleimg img { 45 | max-width: 90%; 46 | max-height: 600px; 47 | /*border: 2px solid #ddd;*/ 48 | } 49 | table { 50 | margin: 0 auto 0.8em; 51 | border-collapse: collapse; 52 | } 53 | td, th { 54 | border: 1px solid #ddd; 55 | padding: 0.3em 0.5em; 56 | } 57 | 58 | .bgheader h1 { 59 | background-color: rgba(0, 0, 0, 0.9); 60 | opacity: 50%; 61 | padding: 0.5em; 62 | color: white; 63 | border-radius: .5em; 64 | } 65 | .middlebelowheader { 66 | /* This fixed size height was found to work well with the slide 67 | scaling mechanism of remark.js: 68 | */ 69 | height: 500px; 70 | display: table-cell; 71 | vertical-align: middle; 72 | } 73 | .widespace h2 { 74 | line-height: 200%; 75 | } 76 | .big .remark-code { 77 | font-size: 200%; 78 | } 79 | .remark-code, .remark-inline-code { 80 | font-family: 'Ubuntu Mono'; 81 | } 82 | 83 | .medium .remark-code { 84 | font-size: 120%; 85 | } 86 | 87 | .mmedium .remark-code { 88 | font-size: 99%; 89 | } 90 | 91 | .affiliations img { 92 | height: 44px; 93 | margin: 2em; 94 | } 95 | 96 | .hidden { 97 | visibility: hidden; 98 | } 99 | 100 | .small { 101 | font-size: 90%; 102 | } 103 | 104 | .credits { 105 | font-style: italic; 106 | font-size: 70%; 107 | } 108 | 109 | .bunchoflogos img { 110 | max-height: 100px; 111 | padding: 1em; 112 | } 113 | 114 | .bunchoflogos p { 115 | text-align: center; 116 | width: 750px; 117 | } 118 | 119 | a:visited { 120 | color: blue; 121 | } 122 | -------------------------------------------------------------------------------- /slides/06_optimization_general/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/07_deep_learning/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/image.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | from PIL import Image 3 | 4 | import numpy as np 5 | 6 | from sklearn.feature_extraction import image 7 | from sklearn.utils import check_random_state 8 | 9 | fig, axes = plt.subplots(10, 10) 10 | axes = axes.ravel() 11 | 12 | data = Image.open('DSC_0360.jpg') 13 | w, h = data.size 14 | data = data.resize((600, 400)) 15 | data = np.array(data) 16 | 17 | patches = image.extract_patches_2d(data, (5, 5)) 18 | 19 | rng = check_random_state(10) 20 | for i, ax in enumerate(axes): 21 | i = rng.randint(len(patches)) 22 | ax.imshow(patches[i].reshape((5, 5, 3))) 23 | ax.axis('off') 24 | plt.savefig('patches.png') 25 | 26 | fig, ax = plt.subplots(1, 1) 27 | ax.imshow(data) 28 | ax.axis('off') 29 | plt.savefig('image.png') 30 | 31 | -------------------------------------------------------------------------------- /slides/07_deep_learning/images/Logo_Master_Datascience.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/Logo_Master_Datascience.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/alexnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/alexnet.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/archievol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/archievol.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/architectures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/architectures.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/assembled-resnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/assembled-resnet.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/augmented-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/augmented-cat.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/deeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/deeper.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/efficientnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/efficientnet.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/heuritech-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/heuritech-logo.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/inception1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/inception1.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/inception2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/inception2.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/inria-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/inria-logo.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/lecunconv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/lecunconv.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/lenet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/lenet.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/no_padding_strides.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/no_padding_strides.gif -------------------------------------------------------------------------------- /slides/07_deep_learning/images/not-augmented-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/not-augmented-cat.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/numerical_no_padding_no_strides.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/numerical_no_padding_no_strides.gif -------------------------------------------------------------------------------- /slides/07_deep_learning/images/numerical_no_padding_no_strides_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/numerical_no_padding_no_strides_00.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/performanceSOTA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/performanceSOTA.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/pooling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/pooling.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/residualblock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/residualblock.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/resnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/resnet.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/same_padding_no_strides.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/same_padding_no_strides.gif -------------------------------------------------------------------------------- /slides/07_deep_learning/images/vgg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/vgg.png -------------------------------------------------------------------------------- /slides/07_deep_learning/images/vision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/images/vision.png -------------------------------------------------------------------------------- /slides/07_deep_learning/patches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/07_deep_learning/patches.png -------------------------------------------------------------------------------- /slides/07_deep_learning/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | font-size: 110%; 8 | 9 | } 10 | 11 | h1, h2, h3, h4, h5, h6 { 12 | font-family: 'Ubuntu'; 13 | font-weight: 300; 14 | margin-top: 0; 15 | } 16 | h1 { 17 | margin-top: 0.5em; 18 | } 19 | h2 { 20 | font-size: 140%; 21 | line-height: 150%; 22 | } 23 | h3 { 24 | font-size: 120%; 25 | line-height: 140%; 26 | } 27 | h2, h3, h4, h5, h6 { 28 | font-weight: normal; 29 | } 30 | 31 | 32 | p, li { 33 | font-size: 120%; 34 | line-height: 140%; 35 | } 36 | 37 | .singleimg .middlebelowheader { 38 | text-align: center; 39 | } 40 | 41 | .singleimg img { 42 | max-width: 90%; 43 | max-height: 600px; 44 | /*border: 2px solid #ddd;*/ 45 | } 46 | table { 47 | margin: 0 auto 0.8em; 48 | border-collapse: collapse; 49 | } 50 | td, th { 51 | border: 1px solid #ddd; 52 | padding: 0.3em 0.5em; 53 | } 54 | 55 | .bgheader h1 { 56 | background-color: rgba(0, 0, 0, 0.9); 57 | opacity: 50%; 58 | padding: 0.5em; 59 | color: white; 60 | border-radius: .5em; 61 | } 62 | .middlebelowheader { 63 | /* This fixed size height was found to work well with the slide 64 | scaling mechanism of remark.js: 65 | */ 66 | height: 500px; 67 | display: table-cell; 68 | vertical-align: middle; 69 | } 70 | .widespace h2 { 71 | line-height: 200%; 72 | } 73 | .big .remark-code { 74 | font-size: 200%; 75 | } 76 | .remark-code, .remark-inline-code { 77 | font-family: 'Ubuntu Mono'; 78 | } 79 | 80 | .medium .remark-code { 81 | font-size: 120%; 82 | } 83 | 84 | .mmedium .remark-code { 85 | font-size: 99%; 86 | } 87 | 88 | .affiliations img { 89 | height: 44px; 90 | margin: 2em; 91 | } 92 | 93 | .hidden { 94 | visibility: hidden; 95 | } 96 | 97 | .small { 98 | font-size: 90%; 99 | } 100 | 101 | .credits { 102 | font-style: italic; 103 | font-size: 70%; 104 | } 105 | 106 | .bunchoflogos img { 107 | max-height: 100px; 108 | padding: 1em; 109 | } 110 | 111 | .bunchoflogos p { 112 | text-align: center; 113 | width: 750px; 114 | } 115 | 116 | a:visited { 117 | color: blue; 118 | } 119 | -------------------------------------------------------------------------------- /slides/07_deep_learning/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/correlation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import matplotlib.pyplot as plt 4 | 5 | fontsize = 18 6 | params = { 7 | 'axes.titlesize': fontsize + 4, 8 | 'axes.labelsize': fontsize + 2, 9 | 'font.size': fontsize + 2, 10 | 'legend.fontsize': fontsize + 2, 11 | 'xtick.labelsize': fontsize, 12 | 'ytick.labelsize': fontsize, 13 | 'text.usetex': True, 14 | 'text.latex.preamble': r'\usepackage{{amsmath}}'} 15 | plt.rcParams.update(params) 16 | 17 | 18 | def plot(C, i, plot_array=False, box=True): 19 | f, ax = plt.subplots(figsize=(3, 3)) 20 | n= 200 21 | x = np.random.randn(n, 2).dot(C.T) 22 | plt.scatter(x[:, 0], x[:, 1], s=10) 23 | plt.xlim([-5, 5]) 24 | plt.ylim([-5, 5]) 25 | s = r'$C = \begin{pmatrix} %d & %d \\ %d & %d \end{pmatrix}$' % (C[0, 0], C[1, 0], C[0, 1], C[1, 1]) 26 | # print(s) 27 | ax.set_yticks([]) 28 | ax.set_xticks([]) 29 | props = dict(boxstyle='round', facecolor='white', alpha=0.8) 30 | plt.savefig('images/correlation_%d0.png' % i, dpi=200) 31 | if box: 32 | plt.text(-2.5, -1, s, bbox=props) 33 | plt.savefig('images/correlation_%d.png' % i, dpi=200) 34 | if plot_array: 35 | u, w = np.linalg.eigh(C) 36 | plt.arrow(0, 0, 3 * w[0, 1], 3 * w[1, 1], width=0.1, color='k') 37 | plt.savefig('images/correlation_%d_array.png' % i, dpi=200) 38 | 39 | 40 | def plotarr(C): 41 | f, ax = plt.subplots(1, 2, figsize=(6, 3)) 42 | n= 200 43 | x = np.random.randn(n, 2).dot(C.T) 44 | ax[0].scatter(x[:, 0], x[:, 1], s=10) 45 | ax[0].set_xlim([-5, 5]) 46 | ax[0].set_ylim([-5, 5]) 47 | # s = r'$C = \begin{pmatrix} %d & %d \\ %d & %d \end{pmatrix}$' % (C[0, 0], C[1, 0], C[0, 1], C[1, 1]) 48 | # print(s) 49 | ax[0].set_yticks([]) 50 | ax[0].set_xticks([]) 51 | props = dict(boxstyle='round', facecolor='white', alpha=0.8) 52 | t = np.linspace(0, np.pi, 100) 53 | c_list = [] 54 | for t_ in t: 55 | c, s = np.cos(t_), np.sin(t_) 56 | z = c * x[:, 0] + s * x[:, 1] 57 | c_list.append(np.mean(z ** 2)) 58 | ax[1].plot(t, c_list) 59 | ax[1].set_xlabel('Angle') 60 | ax[1].set_ylabel('Power') 61 | t = np.linspace(0, np.pi, 20) 62 | f.tight_layout() 63 | for i, t_ in enumerate(t): 64 | c, s = np.cos(t_), np.sin(t_) 65 | ar = ax[0].arrow(0, 0, 3 * c, 3 * s, width=0.1, color='k') 66 | line = ax[1].vlines(t_, 0, 1.1 * np.max(c_list)) 67 | 68 | plt.savefig('images/correlation_pow%d.png' % i, dpi=200) 69 | line.remove() 70 | ar.remove() 71 | 72 | 73 | C_list = [ 74 | [[1, 0], [0, 1]], 75 | [[2, 0], [0, 1]], 76 | [[2, 1], [1, 1]] 77 | ] 78 | 79 | for i, C in enumerate(C_list): 80 | plot(np.array(C), i, plot_array=False) 81 | 82 | plotarr(np.array(C)) 83 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/digits_spectrum.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_digits 3 | import matplotlib.pyplot as plt 4 | 5 | 6 | 7 | X, _ = load_digits(return_X_y=True) 8 | f, ax = plt.subplots(figsize=(4.5, 3)) 9 | X -= np.mean(X, axis=0) 10 | X /= np.std(X) 11 | # X /= np.std(X, axis=0) 12 | e = np.linalg.eigvalsh(np.dot(X.T, X)) 13 | plt.semilogy(e[::-1]) 14 | plt.ylim([1e-2, 1e5]) 15 | x_ = plt.xlabel('Component #') 16 | y_ = plt.ylabel('Power') 17 | plt.savefig('images/spectrum.png', dpi=200, 18 | bbox_extra_artists=[x_, y_], bbox_inches='tight') 19 | 20 | 21 | f, ax = plt.subplots(2, 3, figsize=(6, 4)) 22 | X, _ = load_digits(return_X_y=True) 23 | for i, axe in enumerate(ax.ravel()): 24 | axe.imshow(X[i + 10].reshape(8, 8)) 25 | axe.set_xticks([]) 26 | axe.set_yticks([]) 27 | plt.savefig('images/digits.png', dpi=200) 28 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/dim_red.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_digits 3 | from sklearn.decomposition import PCA 4 | from sklearn.manifold import TSNE 5 | import matplotlib.pyplot as plt 6 | 7 | 8 | X, y = load_digits(return_X_y=True) 9 | 10 | 11 | plt.imshow(X[0].reshape(8, 8)) 12 | plt.savefig('images/digit.png', dpi=200) 13 | plt.close('all') 14 | 15 | 16 | 17 | X_ = TSNE(n_components=2).fit_transform(X) 18 | # X_ = tsne.transform(X) 19 | 20 | f, ax = plt.subplots(figsize=(4, 2.5)) 21 | for i, lab in enumerate(np.unique(y)): 22 | plt.scatter(X_[y == lab, 0], X_[y == lab, 1], label=i) 23 | # plt.legend() 24 | 25 | plt.savefig('images/tsne.png', dpi=200) 26 | 27 | X_ = pca = PCA(n_components=2).fit_transform(X) 28 | f, ax = plt.subplots(figsize=(4, 2.5)) 29 | plt.scatter(X_[:, 0], X_[:, 1], color='k') 30 | 31 | plt.savefig('images/pca_1.png', dpi=200) 32 | for i, lab in enumerate(np.unique(y)): 33 | plt.scatter(X_[y == lab, 0], X_[y == lab, 1], label=i) 34 | # plt.legend() 35 | 36 | plt.savefig('images/pca_2.png', dpi=200) 37 | # plt.show() 38 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/factorization.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.datasets import load_digits 3 | import matplotlib.pyplot as plt 4 | from sklearn.decomposition import PCA, FastICA 5 | 6 | 7 | X = np.random.laplace(size=(2000, 2)) 8 | 9 | X = np.sign(X) * np.abs(X) ** 2 10 | X = X.dot(np.random.randn(2, 2)) 11 | 12 | s=3 13 | f = plt.figure(figsize=(4.5, 2.5)) 14 | plt.scatter(X[:, 0], X[:, 1], s=s) 15 | plt.savefig('images/data.png', dpi=200) 16 | 17 | X_pca = PCA(2).fit_transform(X.copy()) 18 | f = plt.figure(figsize=(4.5, 2.5)) 19 | plt.scatter(X_pca[:, 0], X_pca[:, 1], s=s) 20 | plt.savefig('images/pca_data.png', dpi=200) 21 | 22 | 23 | X_ica = FastICA(2).fit_transform(X.copy()) 24 | f = plt.figure(figsize=(4.5, 2.5)) 25 | plt.scatter(X_ica[:, 0], X_ica[:, 1], s=s) 26 | plt.savefig('images/ica_data.png', dpi=200) 27 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/ica.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import matplotlib.pyplot as plt 4 | 5 | from sklearn.decomposition import PCA, FastICA 6 | import mne 7 | 8 | X = mne.io.read_raw_edf('ecgca444.edf')['data'][0].T 9 | n_ch = X.shape[1] 10 | X = X[40000:50000] 11 | sf = 1000 12 | X -= X.mean(axis=0) 13 | X /= X.std(axis=0) 14 | 15 | 16 | def plot(X_, savename, lim=None): 17 | X = X_.copy() 18 | if lim is not None: 19 | X = X[lim] 20 | f, ax = plt.subplots(figsize=(6, 4)) 21 | n_s, n_f = X.shape 22 | time = np.linspace(0, n_s / sf, n_s) 23 | offset = 0 24 | ax.set_yticks([]) 25 | x_ = ax.set_xlabel('time (sec.)') 26 | for x in X.T: 27 | plt.plot(time, x + offset - x.min()) 28 | offset += 1.1 * (x.max() - x.min()) 29 | plt.savefig(savename, bbox_extra_artists=[x_, ], bbox_inches='tight') 30 | 31 | 32 | lim = None 33 | plot(X, 'images/raw.png', lim) 34 | plot(PCA(n_ch, whiten=True).fit_transform(X.copy()), 'images/raw_pca.png', lim) 35 | plot(FastICA(n_ch).fit_transform(X.copy()), 'images/raw_ica.png', lim) 36 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/activ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/activ.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/cats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/cats.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/catsndogs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/catsndogs.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_%d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_%d.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_0.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_00.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_1.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_10.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_2.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_20.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_2_array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_2_array.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow0.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow1.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow10.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow11.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow12.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow13.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow14.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow15.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow16.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow17.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow18.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow19.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow2.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow3.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow4.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow5.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow6.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow7.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow8.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/correlation_pow9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/correlation_pow9.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/data.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/dict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/dict.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/digit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/digit.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/digits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/digits.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/ecg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/ecg.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/ecg_ica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/ecg_ica.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/gabor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/gabor.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/ica_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/ica_data.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/logo_ens_psl_couleur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/logo_ens_psl_couleur.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/notes.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/pca_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/pca_1.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/pca_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/pca_2.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/pca_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/pca_data.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/raw.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/raw_ica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/raw_ica.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/raw_pca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/raw_pca.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/spect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/spect.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/images/spectrum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/08_unsupervised_learning/images/spectrum.png -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/slides.css: -------------------------------------------------------------------------------- 1 | @import url(webfont-ubuntu-400-300-100.css); 2 | @import url(webfont-ubuntu-mono-400-700-400italic.css); 3 | 4 | body { 5 | font-family: 'Ubuntu'; 6 | font-weight: normal; 7 | } 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | font-family: 'Ubuntu'; 11 | font-weight: 300; 12 | margin-top: 0; 13 | } 14 | h1 { 15 | margin-top: 0.5em; 16 | } 17 | h2 { 18 | font-size: 140%; 19 | line-height: 150%; 20 | } 21 | h3 { 22 | font-size: 120%; 23 | line-height: 140%; 24 | } 25 | h2, h3, h4, h5, h6 { 26 | font-weight: normal; 27 | } 28 | 29 | 30 | li { 31 | font-size: 120%; 32 | line-height: 160%; 33 | } 34 | 35 | p { 36 | font-size: 120%; 37 | line-height: 140%; 38 | } 39 | 40 | .singleimg .middlebelowheader { 41 | text-align: center; 42 | } 43 | 44 | .singleimg img { 45 | max-width: 90%; 46 | max-height: 600px; 47 | /*border: 2px solid #ddd;*/ 48 | } 49 | table { 50 | margin: 0 auto 0.8em; 51 | border-collapse: collapse; 52 | } 53 | td, th { 54 | border: 1px solid #ddd; 55 | padding: 0.3em 0.5em; 56 | } 57 | 58 | .bgheader h1 { 59 | background-color: rgba(0, 0, 0, 0.9); 60 | opacity: 50%; 61 | padding: 0.5em; 62 | color: white; 63 | border-radius: .5em; 64 | } 65 | .middlebelowheader { 66 | /* This fixed size height was found to work well with the slide 67 | scaling mechanism of remark.js: 68 | */ 69 | height: 500px; 70 | display: table-cell; 71 | vertical-align: middle; 72 | } 73 | .widespace h2 { 74 | line-height: 200%; 75 | } 76 | .big .remark-code { 77 | font-size: 200%; 78 | } 79 | .remark-code, .remark-inline-code { 80 | font-family: 'Ubuntu Mono'; 81 | } 82 | 83 | .medium .remark-code { 84 | font-size: 120%; 85 | } 86 | 87 | .mmedium .remark-code { 88 | font-size: 99%; 89 | } 90 | 91 | .affiliations img { 92 | height: 44px; 93 | margin: 2em; 94 | } 95 | 96 | .hidden { 97 | visibility: hidden; 98 | } 99 | 100 | .small { 101 | font-size: 90%; 102 | } 103 | 104 | .credits { 105 | font-style: italic; 106 | font-size: 70%; 107 | } 108 | 109 | .bunchoflogos img { 110 | max-height: 100px; 111 | padding: 1em; 112 | } 113 | 114 | .bunchoflogos p { 115 | text-align: center; 116 | width: 750px; 117 | } 118 | 119 | a:visited { 120 | color: blue; 121 | } 122 | -------------------------------------------------------------------------------- /slides/08_unsupervised_learning/webfont-ubuntu-400-300-100.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Ubuntu'; 4 | font-style: normal; 5 | font-weight: 300; 6 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/X_EdMnknKUltk57alVVbVxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 7 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 8 | } 9 | /* cyrillic */ 10 | @font-face { 11 | font-family: 'Ubuntu'; 12 | font-style: normal; 13 | font-weight: 300; 14 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/nBF2d6Y3AbOwfkBM-9HcWBJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 15 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 16 | } 17 | /* greek-ext */ 18 | @font-face { 19 | font-family: 'Ubuntu'; 20 | font-style: normal; 21 | font-weight: 300; 22 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/CdlIlwqST01WNAKqZbtZkhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 23 | unicode-range: U+1F00-1FFF; 24 | } 25 | /* greek */ 26 | @font-face { 27 | font-family: 'Ubuntu'; 28 | font-style: normal; 29 | font-weight: 300; 30 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/7k0RmqCN8EFxqS6sChuRzRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 31 | unicode-range: U+0370-03FF; 32 | } 33 | /* latin-ext */ 34 | @font-face { 35 | font-family: 'Ubuntu'; 36 | font-style: normal; 37 | font-weight: 300; 38 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/WtcvfJHWXKxx4x0kuS1koRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2'); 39 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 40 | } 41 | /* latin */ 42 | @font-face { 43 | font-family: 'Ubuntu'; 44 | font-style: normal; 45 | font-weight: 300; 46 | src: local('Ubuntu Light'), local('Ubuntu-Light'), url(https://fonts.gstatic.com/s/ubuntu/v9/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2'); 47 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 48 | } 49 | /* cyrillic-ext */ 50 | @font-face { 51 | font-family: 'Ubuntu'; 52 | font-style: normal; 53 | font-weight: 400; 54 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/ODszJI8YqNw8V2xPulzjO_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 55 | unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; 56 | } 57 | /* cyrillic */ 58 | @font-face { 59 | font-family: 'Ubuntu'; 60 | font-style: normal; 61 | font-weight: 400; 62 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/iQ9VJx1UMASKNiGywyyCXvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 63 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 64 | } 65 | /* greek-ext */ 66 | @font-face { 67 | font-family: 'Ubuntu'; 68 | font-style: normal; 69 | font-weight: 400; 70 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/WkvQmvwsfw_KKeau9SlQ2_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 71 | unicode-range: U+1F00-1FFF; 72 | } 73 | /* greek */ 74 | @font-face { 75 | font-family: 'Ubuntu'; 76 | font-style: normal; 77 | font-weight: 400; 78 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/gYAtqXUikkQjyJA1SnpDLvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 79 | unicode-range: U+0370-03FF; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Ubuntu'; 84 | font-style: normal; 85 | font-weight: 400; 86 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/Wu5Iuha-XnKDBvqRwQzAG_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); 87 | unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; 88 | } 89 | /* latin */ 90 | @font-face { 91 | font-family: 'Ubuntu'; 92 | font-style: normal; 93 | font-weight: 400; 94 | src: local('Ubuntu'), url(https://fonts.gstatic.com/s/ubuntu/v9/sDGTilo5QRsfWu6Yc11AXg.woff2) format('woff2'); 95 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; 96 | } 97 | -------------------------------------------------------------------------------- /slides/09_database.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/data-psl/lectures2020/5239d4912eb087dcc0b5351df11bbfb0f74f4bc3/slides/09_database.pdf -------------------------------------------------------------------------------- /slides/README.md: -------------------------------------------------------------------------------- 1 | # Lectures 2 | 3 | 1. [Machine learning: history, application, successes](https://data-psl.github.io/lectures2020/slides/01_machine_learning_successes) 4 | 2. [Introduction to machine learning](https://data-psl.github.io/lectures2020/slides/02_intro_to_machine_learning) 5 | 3. [Supervised machine learning models](https://data-psl.github.io/lectures2020/slides/03_machine_learning_models/) 6 | 4. [Scikit-learn: estimation and pipelines](https://data-psl.github.io/lectures2020/slides/04_scikit_learn/) 7 | 5. [Optimization for linear models](https://data-psl.github.io/lectures2020/slides/05_optimization_linear_models/) 8 | 6. [Optimization for machine learning](https://data-psl.github.io/lectures2020/slides/06_optimization_general/) 9 | 7. [Deep learning: convolutional neural networks](https://data-psl.github.io/lectures2020/slides/07_deep_learning/) 10 | 8. [Unsupervised learning](https://data-psl.github.io/lectures2020/slides/08_unsupervised_learning/) 11 | 9-10. [Introduction to Relational Database Management Systems](https://data-psl.github.io/lectures2020/slides/09_database.pdf) 12 | 13 | ## Acknowledgements 14 | 15 | Some material of this course was borrowed and adapted: 16 | * The slides from ["Deep learning: convolutional neural networks"](https://data-psl.github.io/lectures2020/slides/07_deep_learning/) are adapted from 17 | Charles Ollion and Olivier Grisel's [advanced course on deep learning](!https://github.com/m2dsupsdlclass/lectures-labs) (released under the 18 | [CC-By 4.0 license](https://creativecommons.org/licenses/by/4.0/legalcode)). 19 | --------------------------------------------------------------------------------