Data Science Quiz 5

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

46 Terms

1
New cards

Standardization (Z-Score)

  • z(x) = (x - upside down h) / select o

  • transform N(upside down h, select o) → N(0,1)

  • aggregate stats (mean, s.dev)

  • gaussian distribution

  • inverse formula: z^-1(x) = z(x) * select o + upside down h


2
New cards

Normalization (Min-Max Scaling)

  • n(x) = (x - xmin) / (xmax - xmin)

  • transform [xmin, xmax] → [0,1]

  • range stats (min, max)

  • uniform distribution

  • inverse formula: n^-1(x) = n(x) * (xmax - xmin) + xmin


3
New cards

Standardization & Normalization

  • reign in data variance

  • commonly used in ML

  • good to apply to input features

  • easily invertible

  • adds interpretability


4
New cards

How to Properly Apply Standardization or Normalization

  1. split off your test data and set aside

  2. calculate the necessary statistics on the train labels (either mean/s.dev or max/min)

  3. apply appropriate transform

  4. learn the model using transformed training labels

  5. when testing, perform inference on test input data then apply inverse transform to the predictions before comparing to the test set labels


5
New cards

Scikit Learn Tool For Standardization

StandardScalar

6
New cards

Scikit Learn Tool For Normalization

MinMaxScaler

7
New cards

Outlier

data points that are far away from other data points

8
New cards

What causes outliers?

  • human error

  • natural disasters


9
New cards

Why are outliers bad?

  • MSE/L2 loss heavily vulnerable

  • abnormality


10
New cards

How to detect outliers?

  1. Z-score standardization

  2. interquartile range (IQR) Q3 - Q1

  3. box plots


11
New cards

One-Hot Encoding

useful for input features that themselves are distinct classes/categories

  • introduces a binary feature for each category


12
New cards

Caveats of One-Hot Encoding

  • increases model complexity, might need regularization

  • you must know all the categories you want to consider



13
New cards

Feature Pipelines

allows you to wrap a sequence of transforms and models together as a single python object

14
New cards

Data Imputing

scikit learn’s take on handling missing/NaN values

15
New cards

SVM

  • support vector machine

  • decides the margin classifier

  • margin should be fat (linear separability)


16
New cards

Kernel Transform

  • mapping we apply to data to make it easier to learn from

  • data that is not linearly separable can be converted to be

  • specifically meant for SVM


17
New cards

Kernel Functions

  • polynomial

    • takes existing input features and apply increasing exponents

  • radial basis function

    • new feature is based on distance from fixed point x’

    • many variants depending on how you calculate y’

    • use L1 distance rather than L2


18
New cards

Save File Types

  • PNG

  • PDF

  • JPEG

  • SVG


19
New cards

PDF

used for placing in word docs / powerpoints

20
New cards

PDF

use for embedding in LaTeX documents

21
New cards

JPEG

file size, png is mostly better though

22
New cards

SVG

for specific use cases HiDPI & later editing

23
New cards

Matplotlib Interfaces

  • MATLAB-Style

  • Object-Oriented Style


24
New cards

MATLAB-Style Interface

references the plt object directly to create suplots

25
New cards

Object-Oriented Style

splits plt into fig and ax objects to create subplots

26
New cards

Color Considerations

  • pastel-like shades over high-contrast colors

  • visual comfort and fatigue

  • more professional and better with printing

  • colorblindness


27
New cards

Boilerplate

  • titles for plot and axis

  • plot range limits


28
New cards

Linestyles

  • helps identify different lines in grayscale

  • information is tied to the legend

  • helps colorblind readers


29
New cards

plt.scatter() basic info

  • controls individual points

  • less code than plt.plot()

  • not as efficient for multiple large sequences


30
New cards

plt.plot()

  • line plots

  • continuous functions

  • model-over-time scenarios

  • correlation plots

  • receiver operating characteristic (ROC) curve

  • regression prediction vs. targets


31
New cards

plt.scatter() Pro’s

  • visualizes raw data

  • unsupervised learning

  • clustering

  • dimension reduction


32
New cards

Color Maps

set of one or more colors

33
New cards

Heatmap

  • 3D plot where X and Y are a discrete map

  • made with seaborn


34
New cards

Seaborn

  • fancier package that builds atop of matplotlib

  • new plot functions, overwrites some of matplotlib

  • better at implementing plot cues (such as color)


35
New cards

Histogram Arguments

  • bins: how many vertical columns

  • normed: present as probability pdf plot instead of frequency

  • histype: style of bars


36
New cards

Heatmaps (vs. 2D Histograms)

  • bins for specific ranges/categories

  • 1cm unit of length

  • categorical paper heatmap

  • values in bins are arbitrary

    • correlation metrics

    • no restriction on type


37
New cards

2D Histograms (vs. Heatmaps)

  • bins are arbitrarily decided

  • values in bins are integers

  • exception: converting to probability distribution


38
New cards

Legend loc

  • alternative: bbox_to_anchor for numerical coordinates

  • loc basically allows you to put where legend where you want it


39
New cards

Legend ncol

  • allows you to format the legend as a row, column, or matrix


40
New cards

Legend frameon

  • allows you to add a shadow, borderpad (control the legend border)


41
New cards

Subplots

  • arranged in rows and columns

  • ordered from 1 to n

  • indexed from L → R then top → bottom


42
New cards

Steps to create Inset (magnifying glass)

  1. add a matplotlib rectangle object to the desired region

  2. create the separate inset axes object & position it as you would a legend object

  3. re-do plot functions for inset plot, though it will only display inside zoomed range


43
New cards

3D Plotting

  • adding z-value data

  • changing plot() → plot3D()

  • changing scatter() → scatter3D()


44
New cards

Annotating a plot requires what?

  • code to decide font, color, location, math formatting

  • trial and error to make sure the text and arrows are in the right spot


45
New cards

Tick Bloat

  • caused by default parameters of subplots


46
New cards

plt.Locator()

can trim up number of ticks for the x and y axis