🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 111 (from laksa066)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
22 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.7 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://faculty.washington.edu/otoomet/machinelearning-py/plotting-matplotlib-and-seaborn.html
Last Crawled2026-03-18 09:29:07 (22 days ago)
First Indexed2022-04-04 18:26:51 (4 years ago)
HTTP Status Code200
Meta TitleChapter 4 Plotting: matplotlib and seaborn | Machine learning in python
Meta DescriptionChapter 4 Plotting: matplotlib and seaborn | Machine learning in python
Meta Canonicalnull
Boilerpipe Text
import numpy as np np.random.seed( 10 ) Python has many plotting libraries. Here we discuss some of the simplest ones, matplotlib and seaborn . Matplotlib is in a sense a very basic plotting library, oriented on vectors, not datasets (in this sense comparable to base-R plotting). But it is very widely used, and with a certain effort, it allows to create very nice looking plots. It is also easier to tinker with the lower level features in matplotlib , compared to the more high-level data oriented libraries. Seaborn is such a high-level data oriented plotting library (comparable to ggplot in R in this sense). It has ready-made functionality to pick variables from datasets and modify the visual properties of lines and points depending on other values in data. We assume you have imported the following modules:
Markdown
- [Machine learning using python](https://faculty.washington.edu/otoomet/machinelearning-py/) - [**1** Introduction](https://faculty.washington.edu/otoomet/machinelearning-py/index.html) - [**1\.1** Topics](https://faculty.washington.edu/otoomet/machinelearning-py/index.html#topics) - [**1\.2** Scope of these notes](https://faculty.washington.edu/otoomet/machinelearning-py/index.html#scope-of-these-notes) - [**2** Python](https://faculty.washington.edu/otoomet/machinelearning-py/python.html) - [**2\.1** Installing python](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#installing-python) - [**2\.2** How to Use Python](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#how-to-use-python) - [**2\.2.1** Command line](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#command-line) - [**2\.2.2** IPython: interactive python](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#ipython-interactive-python) - [**2\.2.3** Jupyter notebooks](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#jupyter-notebooks) - [**2\.3** Base language](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#base-language) - [**2\.3.1** A few words about variable names and coding style](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#a-few-words-about-variable-names-and-coding-style) - [**2\.3.2** Code blocks](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#code-blocks) - [**2\.3.3** Variables and assignment](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#variables-and-assignment) - [**2\.3.4** Mathematical, logical and other operators](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#mathematical-logical-and-other-operators) - [**2\.3.5** Strings](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#strings) - [**2\.3.6** Functions](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#functions) - [**2\.4** Collections](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#collections) - [**2\.4.1** Lists](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#py-collections-lists) - [**2\.4.2** Tuples](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#tuples) - [**2\.4.3** Dicts (maps)](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#dicts-maps) - [**2\.4.4** Sets](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#sets) - [**2\.5** Modifiying objects in place](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#py-inplace) - [**2\.5.1** Shallow copy and deep copy](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#py-inplace-shallowdeep) - [**2\.5.2** Methods that return and methods that modify](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#py-inplace-methods) - [**2\.6** Language Constructs](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#language-constructs) - [**2\.6.1** if-elif-else](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#if-elif-else) - [**2\.6.2** for-Loops](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#for-loops) - [**2\.7** Libraries (modules)](https://faculty.washington.edu/otoomet/machinelearning-py/python.html#modules) - [**3** Numpy and Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html) - [**3\.1** Numpy](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy) - [**3\.1.1** Importing numpy](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#importing-numpy) - [**3\.1.2** Array: The Fundamental Data Structure in Numpy](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-array-fundamental-data-structure) - [**3\.1.3** Creating Arrays](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-creating-arrays) - [**3\.1.4** Vectorized Functions (Universal Functions)](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-universal-functions) - [**3\.1.5** Array Indexing and Slicing](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-array-indexing-slicing) - [**3\.1.6** Random numbers](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-random-numbers) - [**3\.1.7** Statistical functions](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#statistical-functions) - [**3\.2** Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pandas) - [**3\.2.1** Series](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pandas-series) - [**3\.2.2** DataFrame](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#dataframe) - [**3\.3** Indexing data frames and *series*](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pandas-indexing-dataframes) - [**3\.3.1** Select variables in data frames](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pd-indexing-select-variables) - [**3\.3.2** Filter observations with logical operations](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pd-indexing-filter-rows) - [**3\.3.3** Positional indexing of Series](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pd-positional-indexing-series) - [**3\.3.4** Positional indexing of data frames](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#numpy-pandas-positional-indexing-dataframes) - [**3\.3.5** Modifying data frames](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#modifying-data-frames) - [**3\.3.6** Indexing: summary and comparison](https://faculty.washington.edu/otoomet/machinelearning-py/numpy-and-pandas.html#pd-indexing-summary-comparison) - [**4** Plotting: *matplotlib* and *seaborn*](https://faculty.washington.edu/otoomet/machinelearning-py/plotting-matplotlib-and-seaborn.html) - [**5** Descriptive Analysis with Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html) - [**5\.1** First steps: know your data](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#descriptive-pandas-know-data) - [**5\.2** What are the values?](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#descriptive-pandas-values) - [**5\.2.1** Different discrete values](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#descriptive-pandas-values-discrete) - [**5\.2.2** Continuous values](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#descriptive-pandas-values-continuous) - [**5\.2.3** Counts and proportions](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#descriptive-pandas-values-counts) - [**5\.3** Filtering data](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pandas-descriptive-filtering-data) - [**5\.4** Selecting variables](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-selecting-variables) - [**5\.4.1** Selecting desired variables](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-select-desired-variables) - [**5\.4.2** Removing undesired variables](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-remove-undesired-variables) - [**5\.5** Grouped operations](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-grouped-operations) - [**5\.6** String operations](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-strings) - [**5\.6.1** Find patterns in strings](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-find-string) - [**5\.6.2** Match a pattern](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-match-string) - [**5\.6.3** Replacing strings](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-analysis-with-pandas.html#pd-descriptive-replace-string) - [**6** Cleaning and Manipulating Data](https://faculty.washington.edu/otoomet/machinelearning-py/cleaning-data.html) - [**6\.1** Missing observations](https://faculty.washington.edu/otoomet/machinelearning-py/cleaning-data.html#cleaning-missing-observations) - [**6\.1.1** How is missing data coded](https://faculty.washington.edu/otoomet/machinelearning-py/cleaning-data.html#how-is-missing-data-coded) - [**6\.1.2** Removing missing observations](https://faculty.washington.edu/otoomet/machinelearning-py/cleaning-data.html#cleaning-data-removing-missings) - [**7** Descriptive Statistics](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html) - [**7\.1** Central Tendency](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html#descriptive-statistics-central-tendency) - [**7\.2** Variability](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html#variability) - [**7\.3** Distributions](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html#distributions) - [**7\.4** Inequality](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html#inequality) - [**7\.4.1** Pareto ratio](https://faculty.washington.edu/otoomet/machinelearning-py/descriptive-statistics.html#inequality-80-20-ratio) - [**8** Web Scraping](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html) - [**8\.1** Before you begin](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#before-you-begin) - [**8\.2** HTML Basics](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#web-scraping-html-basics) - [**8\.2.1** Tags, elements and attributes](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#tags-elements-and-attributes) - [**8\.2.2** Overall structure](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#overall-structure) - [**8\.2.3** Important tags](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#important-tags) - [**8\.3** Beautiful Soup](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#web-scraping-beautiful-soup) - [**8\.3.1** Example html file](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#example-html-file) - [**8\.3.2** Loading Beautiful Soup and opening the data](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#loading-beautiful-soup-and-opening-the-data) - [**8\.3.3** The hard part: navigating the soup and extracting data](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#the-hard-part-navigating-the-soup-and-extracting-data) - [**8\.4** Finding elements on webpage](https://faculty.washington.edu/otoomet/machinelearning-py/web-scraping.html#web-scraping-finding-elements-on-page) - [**9** Linear Algebra](https://faculty.washington.edu/otoomet/machinelearning-py/la.html) - [**9\.1** Numpy Arrays as Vectors and Matrices](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-np) - [**9\.1.1** 1-D Arrays as Vectors](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-np-1d) - [**9\.1.2** 2-D Arrays as Matrices](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-np-2d) - [**9\.1.3** Numpy matrices](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-np-matrices) - [**9\.2** Matrix operations](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-matrix-operations) - [**9\.3** Matrix product](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#la-matrix-product) - [**9\.4** Inverse matrix](https://faculty.washington.edu/otoomet/machinelearning-py/la.html#ls-inversemat) - [**10** Linear Regression](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html) - [**10\.1** Solving Linear Regression Tasks Manually](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#solving-linear-regression-tasks-manually) - [**10\.1.1** The task](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#linear-regression-the-task) - [**10\.1.2** Solve it manually](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#linear-regression-solve-manually) - [**10\.1.3** Create a function to make it more compact](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#create-a-function-to-make-it-more-compact) - [**10\.1.4** Visualize the Regression Line](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#visualize-the-regression-line) - [**10\.2** Linear Regression in python: `statsmodels.formula.api` and `sklearn`](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#linear-regression-statsmodels-sklearn) - [**10\.2.1** Statsmodels and its formula API](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#linear-regression-statsmodels) - [**10\.2.2** *Scikit-learn* and `LinearRegression`](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#linear-regression-sklearn) - [**10\.3** Model Goodness](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#model-goodness) - [**10\.3.1** Create Random Data for Experiments](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#create-random-data-for-experiments) - [**10\.3.2** Compute SSE, TSS, and \\(R^2\\) manually](https://faculty.washington.edu/otoomet/machinelearning-py/linear-regression.html#compute-sse-tss-and-r2-manually) - [**11** Logistic Regression](https://faculty.washington.edu/otoomet/machinelearning-py/logistic-regression.html) - [**11\.1** Do it manually](https://faculty.washington.edu/otoomet/machinelearning-py/logistic-regression.html#logit-manual) - [**11\.2** Logistic Regression in python: `statsmodels.formula.api` and `sklearn`](https://faculty.washington.edu/otoomet/machinelearning-py/logistic-regression.html#logit-python) - [**11\.2.1** Statsmodels and its formula API](https://faculty.washington.edu/otoomet/machinelearning-py/logistic-regression.html#logistic-regression-statsmodels) - [**11\.2.2** Scikit-learn and `LogisticRegression`](https://faculty.washington.edu/otoomet/machinelearning-py/logistic-regression.html#logistic-regression-sklearn) - [**12** Predictions and Model Goodness](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html) - [**12\.1** Predicting with Linear Regression Models](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predicting-linear) - [**12\.1.1** Predicting linear regression outcomes manually](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predicting-linear-manually) - [**12\.1.2** Predicting through *statsmodels* models](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predicting-linear-statsmodels) - [**12\.1.3** Predicting with *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predicting-with-sklearn) - [**12\.2** Predicting with Logistic Regression](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predictions-logistic) - [**12\.2.1** The Model](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predictions-logistic-model) - [**12\.2.2** Predicting the logistic outcome manually](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predictions-logistic-manual) - [**12\.2.3** Predicting with statsmodels](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predictions-logistic-statsmodels) - [**12\.2.4** Predicting with *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#predictions-predictions-logistic-sklearn) - [**12\.3** Confusion Matrix–Based Model Goodness Measures](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#confusion-matrix-based-measures) - [**12\.3.1** The Model](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#confusion-matrix-model) - [**12\.3.2** Confusion Matrix](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#confusion-matrix) - [**12\.3.3** Accuracy, Precision, Recall](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#prediction-cm-apr) - [**12\.4** Decision boundary](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#pred-decisionboundary) - [**12\.4.1** What is decision boundary](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#pred-decisionboundary-whatis) - [**12\.4.2** How to display the decision boundary](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#pred-decisionboundary-display) - [**12\.4.3** Make a function to display the boundary](https://faculty.washington.edu/otoomet/machinelearning-py/predictions-model-goodness.html#pred-decisionboundary-function) - [**13** Overfitting and Validation](https://faculty.washington.edu/otoomet/machinelearning-py/overfitting-validation.html) - [**13\.1** How random data overfits](https://faculty.washington.edu/otoomet/machinelearning-py/overfitting-validation.html#ov-trainvalid) - [**13\.2** Cross-validation](https://faculty.washington.edu/otoomet/machinelearning-py/overfitting-validation.html#cross-validation) - [**14** Machine Learning Workflow](https://faculty.washington.edu/otoomet/machinelearning-py/ml-workflow.html) - [**14\.1** Boston Housing Data](https://faculty.washington.edu/otoomet/machinelearning-py/ml-workflow.html#boston-housing-data) - [**14\.2** Categorization: image recognition](https://faculty.washington.edu/otoomet/machinelearning-py/ml-workflow.html#categorization-image-recognition) - [**14\.3** Training-validation-testing approach](https://faculty.washington.edu/otoomet/machinelearning-py/ml-workflow.html#training-validation-testing-approach) - [**15** Regularization and Feature Selection](https://faculty.washington.edu/otoomet/machinelearning-py/regularization-and-feature-selection.html) - [**15\.1** How highly correlated features fail](https://faculty.washington.edu/otoomet/machinelearning-py/regularization-and-feature-selection.html#how-highly-correlated-features-fail) - [**15\.2** Forward selection](https://faculty.washington.edu/otoomet/machinelearning-py/regularization-and-feature-selection.html#forward-selection) - [**15\.3** Ridge and Lasso regression](https://faculty.washington.edu/otoomet/machinelearning-py/regularization-and-feature-selection.html#ridge-and-lasso-regression) - [**16** Trees and Forests](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html) - [**16\.1** Trees and forests in sklearn](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#trees-sklearn) - [**16\.2** Regression Trees](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#trees-regression) - [**16\.3** Classification Trees](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#trees-classification) - [**16\.3.1** Doing classification trees in *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#trees-classification-sklearn) - [**16\.3.2** Decision boundary](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#trees-classification-dboundary) - [**16\.4** Bagging](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#tree-bagging) - [**16\.5** Random Forests](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#tree-rf) - [**16\.6** Boosting](https://faculty.washington.edu/otoomet/machinelearning-py/trees-forests.html#tree-adaboost) - [**17** Support Vector Machines](https://faculty.washington.edu/otoomet/machinelearning-py/svms.html) - [**17\.1** Yin-Yang Pattern](https://faculty.washington.edu/otoomet/machinelearning-py/svms.html#yin-yang-pattern) - [**17\.2** SVM in *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/svms.html#svm-in-sklearn) - [**17\.3** Find the best model](https://faculty.washington.edu/otoomet/machinelearning-py/svms.html#find-the-best-model) - [**18** Unsupervised Learning](https://faculty.washington.edu/otoomet/machinelearning-py/unsupervised-learning.html) - [**18\.1** Clustering](https://faculty.washington.edu/otoomet/machinelearning-py/unsupervised-learning.html#clustering) - [**18\.1.1** \\(k\\)\-means in *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/unsupervised-learning.html#k-means-sklearn) - [**18\.1.2** Hieararchical clustering in *sklearn*](https://faculty.washington.edu/otoomet/machinelearning-py/unsupervised-learning.html#clustering-hierarchical) - [**19** Neural Networks](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html) - [**19\.1** Multi-Layer Perceptron](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#sklearn-multi-layer-perceptron) - [**19\.2** Convolutional Neural Networks in Keras](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#convolutional-neural-networks-in-keras) - [**19\.2.1** Keras and Tensorflow](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#keras-and-tensorflow) - [**19\.2.2** Example network in *keras*](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#example-network-keras) - [**19\.3** Image processing with convolutional networks](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions) - [**19\.3.1** Loading Data](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions-loading-data) - [**19\.3.2** Building the Model](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions-building-model) - [**19\.3.3** Compile the model](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#nnet-img-compile) - [**19\.3.4** Train the model](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#nnet-img-train) - [**19\.3.5** Common model errors](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions-common-model-errors) - [**19\.3.6** Training the model](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions-training-model) - [**19\.3.7** Predictions and Validation](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#neural-nets-keras-convolutions-predictions-validation) - [**19\.3.8** Analyzing the model](https://faculty.washington.edu/otoomet/machinelearning-py/neural-networks.html#nnets-image-analyzing) - [**20** Machine learning technicques](https://faculty.washington.edu/otoomet/machinelearning-py/mltech.html) - [**20\.1** Gradient descent](https://faculty.washington.edu/otoomet/machinelearning-py/mltech.html#mltech-gd) - [**20\.1.1** Vector functions](https://faculty.washington.edu/otoomet/machinelearning-py/mltech.html#mltech-gd-vectfcn) - [**20\.1.2** Visualizing the function and gradient](https://faculty.washington.edu/otoomet/machinelearning-py/mltech.html#mltech-gd-viz) - [**21** Working With Images {working-with-images}](https://faculty.washington.edu/otoomet/machinelearning-py/working-with-images-working-with-images.html) - [**21\.1** Loading images](https://faculty.washington.edu/otoomet/machinelearning-py/working-with-images-working-with-images.html#loading-images) - [**22** Natural Language Processing: Text As Data](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html) - [**22\.1** Preparing text](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#preparing-text) - [**22\.1.1** Cleaning and homogenizing text](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#cleaning-and-homogenizing-text) - [**22\.1.2** Tokenization](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#tokenization) - [**22\.1.3** Stemming](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#stemming) - [**22\.1.4** Lemmatization](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#lemmatization) - [**22\.1.5** Ngrams](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#ngrams) - [**22\.2** Converting text to numbers](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#converting-text-to-numbers) - [**22\.2.1** Bag-of-words and Document-term-matrix](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#bag-of-words-and-document-term-matrix) - [**22\.2.2** Example: categorize text](https://faculty.washington.edu/otoomet/machinelearning-py/natural-language-processing-text-data.html#nlp-textnum-categorize) - [**23** Dataset description](https://faculty.washington.edu/otoomet/machinelearning-py/datasets.html) - [**23\.1** Boston housing](https://faculty.washington.edu/otoomet/machinelearning-py/datasets.html#dat-boston) - [**23\.2** Titanic](https://faculty.washington.edu/otoomet/machinelearning-py/datasets.html#datasets-titanic) - [**23\.3** Yin-Yang](https://faculty.washington.edu/otoomet/machinelearning-py/datasets.html#datasets-yinyang) - **Appendix** - [**A** Solutions](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html) - [**A.1** Python](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#python-1) - [**A.1.1** Operators](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#operators) - [**A.1.2** Strings](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#strings-1) - [**A.1.3** Collections](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#collections-1) - [**A.1.4** Language Constructs](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#language-constructs-1) - [**A.1.5** Modules](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#modules-1) - [**A.2** Numpy and Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#numpy-and-pandas-1) - [**A.2.1** Numpy](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#numpy-1) - [**A.2.2** Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#pandas-1) - [**A.3** Descriptive analysis with Pandas](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#descriptive-analysis-with-pandas-1) - [**A.3.1** What are the values?](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#what-are-the-values) - [**A.4** Cleaning and Manipulating Data](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#cleaning-and-manipulating-data) - [**A.4.1** Missing Observations](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#missing-observations) - [**A.4.2** Converting Variables](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#converting-variables) - [**A.5** Descriptive Statistics](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#descriptive-statistics-1) - [**A.5.1** Inequality](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#inequality-1) - [**A.6** Linear Algebra](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#linear-algebra) - [**A.6.1** Numpy Arrays as Vectors and Matrices](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#numpy-arrays-as-vectors-and-matrices) - [**A.7** Linear Regression](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#linear-regression-1) - [**A.7.1** Linear Regression in python: `statsmodels.formula.api` and `sklearn`](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#linear-regression-in-python-statsmodels.formula.api-and-sklearn) - [**A.7.2** Model Goodness](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#model-goodness-1) - [**A.8** Logistic Regression](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#logistic-regression-1) - [**A.8.1** Logistic Regression in python: statsmodels.formula.api and sklearn](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#logistic-regression-in-python-statsmodels.formula.api-and-sklearn) - [**A.9** Predictions and Model Goodness](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#predictions-and-model-goodness) - [**A.9.1** Predicting using linear regression](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#predicting-using-linear-regression) - [**A.9.2** Predicting with Logistic Regression](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#predicting-with-logistic-regression) - [**A.9.3** Confusion Matrix–Based Model Goodness Measures](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#confusion-matrixbased-model-goodness-measures) - [**A.10** Trees and Forests](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#solution-trees-forests) - [**A.10.1** Regression Trees](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#solution-regression-trees) - [**A.11** Machine learning techniques](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#sol-mltech) - [**A.11.1** Gradient descent](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#sol-mltech-gd) - [**A.12** Natural Language Processing](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#natural-language-processing) - [**A.12.1** Categorize text](https://faculty.washington.edu/otoomet/machinelearning-py/solutions.html#categorize-text) - [Published with bookdown](https://github.com/rstudio/bookdown) # [Machine learning in python](https://faculty.washington.edu/otoomet/machinelearning-py/) # Chapter 4 Plotting: *matplotlib* and *seaborn* ``` import numpy as np np.random.seed(10) ``` Python has many plotting libraries. Here we discuss some of the simplest ones, *matplotlib* and *seaborn*. *Matplotlib* is in a sense a very basic plotting library, oriented on vectors, not datasets (in this sense comparable to base-R plotting). But it is very widely used, and with a certain effort, it allows to create very nice looking plots. It is also easier to tinker with the lower level features in *matplotlib*, compared to the more high-level data oriented libraries. Seaborn is such a high-level data oriented plotting library (comparable to *ggplot* in R in this sense). It has ready-made functionality to pick variables from datasets and modify the visual properties of lines and points depending on other values in data. We assume you have imported the following modules:
Readable Markdown
``` import numpy as np np.random.seed(10) ``` Python has many plotting libraries. Here we discuss some of the simplest ones, *matplotlib* and *seaborn*. *Matplotlib* is in a sense a very basic plotting library, oriented on vectors, not datasets (in this sense comparable to base-R plotting). But it is very widely used, and with a certain effort, it allows to create very nice looking plots. It is also easier to tinker with the lower level features in *matplotlib*, compared to the more high-level data oriented libraries. Seaborn is such a high-level data oriented plotting library (comparable to *ggplot* in R in this sense). It has ready-made functionality to pick variables from datasets and modify the visual properties of lines and points depending on other values in data. We assume you have imported the following modules:
Shard111 (laksa)
Root Hash13741598130800272711
Unparsed URLedu,washington!faculty,/otoomet/machinelearning-py/plotting-matplotlib-and-seaborn.html s443