Merge branch 'master' of https://github.com/Dekker1/ResearchMethods
This commit is contained in:
commit
6b3cddc2d1
226
.gitignore
vendored
226
.gitignore
vendored
@ -1,3 +1,225 @@
|
||||
wk7/.ipynb_checkpoints/
|
||||
wk8/.ipynb_checkpoints/
|
||||
.ipynb_checkpoints/
|
||||
|
||||
*~
|
||||
## Core latex/pdflatex auxiliary files:
|
||||
*.aux
|
||||
*.lof
|
||||
*.log
|
||||
*.lot
|
||||
*.fls
|
||||
*.out
|
||||
*.toc
|
||||
*.fmt
|
||||
*.fot
|
||||
*.cb
|
||||
*.cb2
|
||||
|
||||
## Intermediate documents:
|
||||
*.dvi
|
||||
*-converted-to.*
|
||||
# these rules might exclude image files for figures etc.
|
||||
# *.ps
|
||||
# *.eps
|
||||
# *.pdf
|
||||
|
||||
## Generated if empty string is given at "Please type another file name for output:"
|
||||
wk7/week7.pdf
|
||||
wk8/week8.pdf
|
||||
wk9/week9.pdf
|
||||
|
||||
## Bibliography auxiliary files (bibtex/biblatex/biber):
|
||||
*.bbl
|
||||
*.bcf
|
||||
*.blg
|
||||
*-blx.aux
|
||||
*-blx.bib
|
||||
*.run.xml
|
||||
|
||||
## Build tool auxiliary files:
|
||||
*.fdb_latexmk
|
||||
*.synctex
|
||||
*.synctex(busy)
|
||||
*.synctex.gz
|
||||
*.synctex.gz(busy)
|
||||
*.pdfsync
|
||||
|
||||
## Auxiliary and intermediate files from other packages:
|
||||
# algorithms
|
||||
*.alg
|
||||
*.loa
|
||||
|
||||
# achemso
|
||||
acs-*.bib
|
||||
|
||||
# amsthm
|
||||
*.thm
|
||||
|
||||
# beamer
|
||||
*.nav
|
||||
*.pre
|
||||
*.snm
|
||||
*.vrb
|
||||
|
||||
# changes
|
||||
*.soc
|
||||
|
||||
# cprotect
|
||||
*.cpt
|
||||
|
||||
# elsarticle (documentclass of Elsevier journals)
|
||||
*.spl
|
||||
|
||||
# endnotes
|
||||
*.ent
|
||||
|
||||
# fixme
|
||||
*.lox
|
||||
|
||||
# feynmf/feynmp
|
||||
*.mf
|
||||
*.mp
|
||||
*.t[1-9]
|
||||
*.t[1-9][0-9]
|
||||
*.tfm
|
||||
|
||||
#(r)(e)ledmac/(r)(e)ledpar
|
||||
*.end
|
||||
*.?end
|
||||
*.[1-9]
|
||||
*.[1-9][0-9]
|
||||
*.[1-9][0-9][0-9]
|
||||
*.[1-9]R
|
||||
*.[1-9][0-9]R
|
||||
*.[1-9][0-9][0-9]R
|
||||
*.eledsec[1-9]
|
||||
*.eledsec[1-9]R
|
||||
*.eledsec[1-9][0-9]
|
||||
*.eledsec[1-9][0-9]R
|
||||
*.eledsec[1-9][0-9][0-9]
|
||||
*.eledsec[1-9][0-9][0-9]R
|
||||
|
||||
# glossaries
|
||||
*.acn
|
||||
*.acr
|
||||
*.glg
|
||||
*.glo
|
||||
*.gls
|
||||
*.glsdefs
|
||||
|
||||
# gnuplottex
|
||||
*-gnuplottex-*
|
||||
|
||||
# gregoriotex
|
||||
*.gaux
|
||||
*.gtex
|
||||
|
||||
# hyperref
|
||||
*.brf
|
||||
|
||||
# knitr
|
||||
*-concordance.tex
|
||||
# TODO Comment the next line if you want to keep your tikz graphics files
|
||||
*.tikz
|
||||
*-tikzDictionary
|
||||
|
||||
# listings
|
||||
*.lol
|
||||
|
||||
# makeidx
|
||||
*.idx
|
||||
*.ilg
|
||||
*.ind
|
||||
*.ist
|
||||
|
||||
# minitoc
|
||||
*.maf
|
||||
*.mlf
|
||||
*.mlt
|
||||
*.mtc[0-9]*
|
||||
*.slf[0-9]*
|
||||
*.slt[0-9]*
|
||||
*.stc[0-9]*
|
||||
|
||||
# minted
|
||||
_minted*
|
||||
*.pyg
|
||||
|
||||
# morewrites
|
||||
*.mw
|
||||
|
||||
# nomencl
|
||||
*.nlo
|
||||
|
||||
# pax
|
||||
*.pax
|
||||
|
||||
# pdfpcnotes
|
||||
*.pdfpc
|
||||
|
||||
# sagetex
|
||||
*.sagetex.sage
|
||||
*.sagetex.py
|
||||
*.sagetex.scmd
|
||||
|
||||
# scrwfile
|
||||
*.wrt
|
||||
|
||||
# sympy
|
||||
*.sout
|
||||
*.sympy
|
||||
sympy-plots-for-*.tex/
|
||||
|
||||
# pdfcomment
|
||||
*.upa
|
||||
*.upb
|
||||
|
||||
# pythontex
|
||||
*.pytxcode
|
||||
pythontex-files-*/
|
||||
|
||||
# thmtools
|
||||
*.loe
|
||||
|
||||
# TikZ & PGF
|
||||
*.dpth
|
||||
*.md5
|
||||
*.auxlock
|
||||
|
||||
# todonotes
|
||||
*.tdo
|
||||
|
||||
# easy-todo
|
||||
*.lod
|
||||
|
||||
# xindy
|
||||
*.xdy
|
||||
|
||||
# xypic precompiled matrices
|
||||
*.xyc
|
||||
|
||||
# endfloat
|
||||
*.ttt
|
||||
*.fff
|
||||
|
||||
# Latexian
|
||||
TSWLatexianTemp*
|
||||
|
||||
## Editors:
|
||||
# WinEdt
|
||||
*.bak
|
||||
*.sav
|
||||
|
||||
# Texpad
|
||||
.texpadtmp
|
||||
|
||||
# Kile
|
||||
*.backup
|
||||
|
||||
# KBibTeX
|
||||
*~[0-9]*
|
||||
|
||||
# auto folder when using emacs and auctex
|
||||
/auto/*
|
||||
|
||||
# expex forward references with \gathertags
|
||||
*-tags.tex
|
||||
|
31
wk7/week7.tex
Normal file
31
wk7/week7.tex
Normal file
@ -0,0 +1,31 @@
|
||||
\documentclass[a4paper]{article}
|
||||
% To compile PDF run: latexmk -pdf {filename}.tex
|
||||
% Math package
|
||||
\usepackage{amsmath}
|
||||
%enable \cref{...} and \Cref{...} instead of \ref: Type of reference included in the link
|
||||
\usepackage[capitalise,nameinlink]{cleveref}
|
||||
% Enable that parameters of \cref{}, \ref{}, \cite{}, ... are linked so that a reader can click on the number an jump to the target in the document
|
||||
\usepackage{hyperref}
|
||||
% UTF-8 encoding
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc} %support umlauts in the input
|
||||
% Easier compilation
|
||||
\usepackage{bookmark}
|
||||
|
||||
\begin{document}
|
||||
\title{Week 7 - Evidence and experiments}
|
||||
\author{
|
||||
Jai Bheeman \and Kelvin Davis \and Jip J. Dekker \and Nelson Frew \and Tony
|
||||
Silvestere
|
||||
}
|
||||
\maketitle
|
||||
|
||||
\section{Introduction} \label{sec:introduction}
|
||||
|
||||
\section{Method} \label{sec:method}
|
||||
|
||||
\section{Results} \label{sec:results}
|
||||
|
||||
\section{Discussion} \label{sec:discussion}
|
||||
|
||||
\end{document}
|
644
wk7/wk7.ipynb
644
wk7/wk7.ipynb
File diff suppressed because one or more lines are too long
32
wk8/week8.tex
Normal file
32
wk8/week8.tex
Normal file
@ -0,0 +1,32 @@
|
||||
\documentclass[a4paper]{article}
|
||||
% To compile PDF run: latexmk -pdf {filename}.tex
|
||||
|
||||
% Math package
|
||||
\usepackage{amsmath}
|
||||
%enable \cref{...} and \Cref{...} instead of \ref: Type of reference included in the link
|
||||
\usepackage[capitalise,nameinlink]{cleveref}
|
||||
% Enable that parameters of \cref{}, \ref{}, \cite{}, ... are linked so that a reader can click on the number an jump to the target in the document
|
||||
\usepackage{hyperref}
|
||||
% UTF-8 encoding
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc} %support umlauts in the input
|
||||
% Easier compilation
|
||||
\usepackage{bookmark}
|
||||
|
||||
\begin{document}
|
||||
\title{Week 8 - Quantitative data analysis}
|
||||
\author{
|
||||
Jai Bheeman \and Kelvin Davis \and Jip J. Dekker \and Nelson Frew \and Tony
|
||||
Silvestere
|
||||
}
|
||||
\maketitle
|
||||
|
||||
\section{Introduction} \label{sec:introduction}
|
||||
|
||||
\section{Method} \label{sec:method}
|
||||
|
||||
\section{Results} \label{sec:results}
|
||||
|
||||
\section{Discussion} \label{sec:discussion}
|
||||
|
||||
\end{document}
|
Binary file not shown.
BIN
wk9/pearson.png
Normal file
BIN
wk9/pearson.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
BIN
wk9/spearman.png
Normal file
BIN
wk9/spearman.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
113
wk9/week9.tex
Normal file
113
wk9/week9.tex
Normal file
@ -0,0 +1,113 @@
|
||||
\documentclass[a4paper]{article}
|
||||
% To compile PDF run: latexmk -pdf {filename}.tex
|
||||
|
||||
% Math package
|
||||
\usepackage{amsmath}
|
||||
%enable \cref{...} and \Cref{...} instead of \ref: Type of reference included in the link
|
||||
\usepackage[capitalise,nameinlink]{cleveref}
|
||||
% Enable that parameters of \cref{}, \ref{}, \cite{}, ... are linked so that a reader can click on the number an jump to the target in the document
|
||||
\usepackage{hyperref}
|
||||
% UTF-8 encoding
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc} %support umlauts in the input
|
||||
% Easier compilation
|
||||
\usepackage{bookmark}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\begin{document}
|
||||
\title{Week 9 - Correlation and Regression}
|
||||
\author{
|
||||
Jai Bheeman \and Kelvin Davis \and Jip J. Dekker \and Nelson Frew \and Tony
|
||||
Silvestere
|
||||
}
|
||||
\maketitle
|
||||
|
||||
\section{Introduction} \label{sec:introduction}
|
||||
We present a report on the relationship between the heights and weights of the
|
||||
top tennis players as catalogued in provided data. We use statistical analysis
|
||||
techniques to numerically describe the characteristics of the data, to see how
|
||||
trends are exhibited within the data set. We conclude the report with a brief
|
||||
discussion of the implications of the analysis and provide insights on
|
||||
potential correlations that may exist.
|
||||
|
||||
\section{Method} \label{sec:method}
|
||||
Provided with a set of 132 unique records of the top 200 male tennis players,
|
||||
we sought to investigate the relationship between the height of particular
|
||||
individuals with their respective weights. We conducted basic statistical
|
||||
correlation analyses of the two variables with both Pearson's and Spearman's
|
||||
correlation coefficients to achieve this. Further, to understand the
|
||||
correlations more deeply, we carried out these correlation tests on the full
|
||||
population of cleaned data (removed duplicates etc), alongside several random
|
||||
samples and samples of ranking ranges within the top 200. To this end, we made
|
||||
use of Microsoft Excel tools and functions of the Python library SciPy.
|
||||
|
||||
We specifically have made use of these separate statistical analysis tools in the
|
||||
interest of sanity checking our findings. To do this, we simply replicated the
|
||||
correlation tests within other software environments.
|
||||
|
||||
\section{Results} \label{sec:results}
|
||||
We performed separate statistical analyses on 10 different samples of the
|
||||
population, as well as the population itself. This included 11 separate
|
||||
subsets of the rankings:
|
||||
\begin{itemize}
|
||||
\item The top 20 entries
|
||||
\item The middle 20 entries
|
||||
\item The bottom 20 entries
|
||||
\item The top 50 entries
|
||||
\item The bottom 50 entries
|
||||
\item 5 randomly chosen sets of 20 entries
|
||||
\end{itemize}
|
||||
\vspace{1em}
|
||||
Table \ref{tab:excel_results} shows the the results for the conducted tests.
|
||||
|
||||
\begin{table}[ht]
|
||||
\centering
|
||||
\label{tab:excel_results}
|
||||
\begin{tabular}{|l|r|r|}
|
||||
\hline
|
||||
\textbf{Test Set} & \textbf{Pearson's Coefficient} & \textbf{Spearman's Coefficient} \\
|
||||
\hline
|
||||
\textbf{Full Population} & 0.77953 & 0.73925 \\
|
||||
\textbf{Top 20} & 0.80743 & 0.80345 \\
|
||||
\textbf{Middle 20} & 0.54134 & 0.36565 \\
|
||||
\textbf{Bottom 20} & 0.84046 & 0.88172 \\
|
||||
\textbf{Top 50} & 0.80072 & 0.78979 \\
|
||||
\textbf{Bottom 50} & 0.84237 & 0.81355 \\
|
||||
\textbf{Random Set \#1} & 0.84243 & 0.80237 \\
|
||||
\textbf{Random Set \#2} & 0.56564 & 0.58714 \\
|
||||
\textbf{Random Set \#3} & 0.59223 & 0.63662 \\
|
||||
\textbf{Random Set \#4} & 0.65091 & 0.58471 \\
|
||||
\textbf{Random Set \#5} & 0.86203 & 0.77832
|
||||
\\ \hline
|
||||
\end{tabular}
|
||||
\caption{Table showing the correlation coefficients between height and
|
||||
weight using different test sets. All data is rounded to 5 decimal
|
||||
places}
|
||||
\end{table}
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\label{fig:scipy}
|
||||
\includegraphics[width=0.6\textwidth]{pearson.png}
|
||||
\includegraphics[width=0.6\textwidth]{spearman.png}
|
||||
\caption{The Pearsion (top) and Spearman (bottom) correlations coefficients
|
||||
of the data set as computed by the Pandas Python library}
|
||||
\end{figure}
|
||||
|
||||
\section{Discussion} \label{sec:discussion}
|
||||
The results generally indicate that there is a fairly strong positive
|
||||
correlation between the weight and weight of an individual tennis player,
|
||||
within the top 200 male players. The population maintains a strong positive
|
||||
correlation with both Pearson's and Spearman's correlation coefficients,
|
||||
indicating that a relationship may exist. Our population samples show
|
||||
promising consistency with this, with 6 seperate samples having values above
|
||||
0.6 with both techniques. The sample taken from the middle 20 players,
|
||||
however, shows a relatively weaker correlation compared with the top 20 and
|
||||
middle 20, which provides some insight into the distribution of the strongest
|
||||
correlated heights and weights amongst the rankings. All five random samples
|
||||
of 20 taken from the population indicate however that there does appear to be
|
||||
a consistent trend through the population, which corresponds accurately with
|
||||
the coefficients on the general population.
|
||||
|
||||
|
||||
\end{document}
|
252
wk9/wk9.ipynb
Normal file
252
wk9/wk9.ipynb
Normal file
@ -0,0 +1,252 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Using matplotlib backend: MacOSX\n",
|
||||
"Populating the interactive namespace from numpy and matplotlib\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%pylab\n",
|
||||
"%matplotlib inline\n",
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from scipy import stats\n",
|
||||
"from matplotlib import colors\n",
|
||||
"\n",
|
||||
"data = pd.read_csv(\"Tennis players 2017-09.csv\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<style type=\"text/css\" >\n",
|
||||
" #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col0 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col1 {\n",
|
||||
" background-color: #ffd20c;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col2 {\n",
|
||||
" background-color: #ffe619;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col3 {\n",
|
||||
" background-color: #f1f44d;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col0 {\n",
|
||||
" background-color: #ffd20c;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col1 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col2 {\n",
|
||||
" background-color: #e4ff7a;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col3 {\n",
|
||||
" background-color: #e8fc6c;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col0 {\n",
|
||||
" background-color: #ffe619;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col1 {\n",
|
||||
" background-color: #e4ff7a;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col2 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col3 {\n",
|
||||
" background-color: #fe9800;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col0 {\n",
|
||||
" background-color: #f1f44d;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col1 {\n",
|
||||
" background-color: #e8fc6c;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col2 {\n",
|
||||
" background-color: #fe9800;\n",
|
||||
" } #T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col3 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" }</style> \n",
|
||||
"<table id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2\" > \n",
|
||||
"<thead> <tr> \n",
|
||||
" <th class=\"blank level0\" ></th> \n",
|
||||
" <th class=\"col_heading level0 col0\" >DOB</th> \n",
|
||||
" <th class=\"col_heading level0 col1\" >RANK</th> \n",
|
||||
" <th class=\"col_heading level0 col2\" >HEIGHT</th> \n",
|
||||
" <th class=\"col_heading level0 col3\" >Weight</th> \n",
|
||||
" </tr></thead> \n",
|
||||
"<tbody> <tr> \n",
|
||||
" <th id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2level0_row0\" class=\"row_heading level0 row0\" >DOB</th> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col0\" class=\"data row0 col0\" >1</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col1\" class=\"data row0 col1\" >0.277766</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col2\" class=\"data row0 col2\" >0.139684</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row0_col3\" class=\"data row0 col3\" >-0.030479</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2level0_row1\" class=\"row_heading level0 row1\" >RANK</th> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col0\" class=\"data row1 col0\" >0.277766</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col1\" class=\"data row1 col1\" >1</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col2\" class=\"data row1 col2\" >-0.16755</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row1_col3\" class=\"data row1 col3\" >-0.121946</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2level0_row2\" class=\"row_heading level0 row2\" >HEIGHT</th> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col0\" class=\"data row2 col0\" >0.139684</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col1\" class=\"data row2 col1\" >-0.16755</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col2\" class=\"data row2 col2\" >1</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row2_col3\" class=\"data row2 col3\" >0.779526</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2level0_row3\" class=\"row_heading level0 row3\" >Weight</th> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col0\" class=\"data row3 col0\" >-0.030479</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col1\" class=\"data row3 col1\" >-0.121946</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col2\" class=\"data row3 col2\" >0.779526</td> \n",
|
||||
" <td id=\"T_7277b07a_4f3e_11e8_b8a3_787b8ab7acb2row3_col3\" class=\"data row3 col3\" >1</td> \n",
|
||||
" </tr></tbody> \n",
|
||||
"</table> "
|
||||
],
|
||||
"text/plain": [
|
||||
"<pandas.io.formats.style.Styler at 0x1a197d7b38>"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def background_gradient(s, m, M, cmap='Wistia', low=0, high=0):\n",
|
||||
" rng = M - m\n",
|
||||
" norm = colors.Normalize(m - (rng * low),\n",
|
||||
" M + (rng * high))\n",
|
||||
" normed = norm(s.values)\n",
|
||||
" c = [colors.rgb2hex(x) for x in plt.cm.get_cmap(cmap)(normed)]\n",
|
||||
" return ['background-color: %s' % color for color in c]\n",
|
||||
"\n",
|
||||
"data = data[[\"SEX\", \"DOB\", \"RANK\", \"HANDED\", \"Country\", \"HEIGHT\", \"Weight\"]]\n",
|
||||
"data.drop_duplicates\n",
|
||||
"\n",
|
||||
"pearson = data.corr()\n",
|
||||
"pearson.style.apply(background_gradient,\n",
|
||||
" cmap='Wistia',\n",
|
||||
" m=pearson.min().min(),\n",
|
||||
" M=pearson.max().max()\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<style type=\"text/css\" >\n",
|
||||
" #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col0 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col1 {\n",
|
||||
" background-color: #ffd20c;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col2 {\n",
|
||||
" background-color: #fee91d;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col3 {\n",
|
||||
" background-color: #f4f242;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col0 {\n",
|
||||
" background-color: #ffd20c;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col1 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col2 {\n",
|
||||
" background-color: #e4ff7a;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col3 {\n",
|
||||
" background-color: #eafa63;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col0 {\n",
|
||||
" background-color: #fee91d;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col1 {\n",
|
||||
" background-color: #e4ff7a;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col2 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col3 {\n",
|
||||
" background-color: #ff9d00;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col0 {\n",
|
||||
" background-color: #f4f242;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col1 {\n",
|
||||
" background-color: #eafa63;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col2 {\n",
|
||||
" background-color: #ff9d00;\n",
|
||||
" } #T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col3 {\n",
|
||||
" background-color: #fc7f00;\n",
|
||||
" }</style> \n",
|
||||
"<table id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2\" > \n",
|
||||
"<thead> <tr> \n",
|
||||
" <th class=\"blank level0\" ></th> \n",
|
||||
" <th class=\"col_heading level0 col0\" >DOB</th> \n",
|
||||
" <th class=\"col_heading level0 col1\" >RANK</th> \n",
|
||||
" <th class=\"col_heading level0 col2\" >HEIGHT</th> \n",
|
||||
" <th class=\"col_heading level0 col3\" >Weight</th> \n",
|
||||
" </tr></thead> \n",
|
||||
"<tbody> <tr> \n",
|
||||
" <th id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2level0_row0\" class=\"row_heading level0 row0\" >DOB</th> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col0\" class=\"data row0 col0\" >1</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col1\" class=\"data row0 col1\" >0.280386</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col2\" class=\"data row0 col2\" >0.122412</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row0_col3\" class=\"data row0 col3\" >0.00769861</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2level0_row1\" class=\"row_heading level0 row1\" >RANK</th> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col0\" class=\"data row1 col0\" >0.280386</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col1\" class=\"data row1 col1\" >1</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col2\" class=\"data row1 col2\" >-0.160006</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row1_col3\" class=\"data row1 col3\" >-0.0908714</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2level0_row2\" class=\"row_heading level0 row2\" >HEIGHT</th> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col0\" class=\"data row2 col0\" >0.122412</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col1\" class=\"data row2 col1\" >-0.160006</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col2\" class=\"data row2 col2\" >1</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row2_col3\" class=\"data row2 col3\" >0.739246</td> \n",
|
||||
" </tr> <tr> \n",
|
||||
" <th id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2level0_row3\" class=\"row_heading level0 row3\" >Weight</th> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col0\" class=\"data row3 col0\" >0.00769861</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col1\" class=\"data row3 col1\" >-0.0908714</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col2\" class=\"data row3 col2\" >0.739246</td> \n",
|
||||
" <td id=\"T_727bef98_4f3e_11e8_a315_787b8ab7acb2row3_col3\" class=\"data row3 col3\" >1</td> \n",
|
||||
" </tr></tbody> \n",
|
||||
"</table> "
|
||||
],
|
||||
"text/plain": [
|
||||
"<pandas.io.formats.style.Styler at 0x111a3b198>"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"spearman = data.corr(method=\"spearman\")\n",
|
||||
"spearman.style.apply(background_gradient,\n",
|
||||
" cmap='Wistia',\n",
|
||||
" m=spearman.min().min(),\n",
|
||||
" M=spearman.max().max()\n",
|
||||
")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Reference in New Issue
Block a user