CS 111: Program Design I Lecture #26: Heat maps, Nothing, Predictive Policing

Similar documents
CS 111: Program Design I Lecture 15: Objects, Pandas, Modules. Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016

CS 111: Program Design I Lecture 15: Modules, Pandas again. Robert H. Sloan & Richard Warner University of Illinois at Chicago March 8, 2018

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions

CS 111: Program Design I Lecture 25: Social networks, nothingness. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 24, 2018

Lecture 9: Exam I Review

CS 111: Program Design I Lecture 21: Network Analysis. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 10, 2018

CS 111: Program Design I Lecture # 7: Web Crawler, Functions; Open Access

CS 111: Program Design I Lecture 16: Module Review, Encodings, Lists

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python

CS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts

CSE 111 Bio: Program Design I Lecture 17: software development, list methods

Python Programming: An Introduction to Computer Science

CS 111: Program Design I Lecture 5: US Law when others have encryption keys; if, for

Python Programming: An Introduction to Computer Science

CS 111: Program Design I Lecture 18: Web and getting text from it

CS 11 C track: lecture 1

CS 111: Program Design I Lecture 14: Encodings & Files concluded; Pandas, Modules, legal data analytics

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright

SD vs. SD + One of the most important uses of sample statistics is to estimate the corresponding population parameters.

CSE 111 Bio: Program Design I Class 11: loops

Pattern Recognition Systems Lab 1 Least Mean Squares

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0

Learning to Shoot a Goal Lecture 8: Learning Models and Skills

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

Lecture 1: Introduction and Strassen s Algorithm

Administrative UNSUPERVISED LEARNING. Unsupervised learning. Supervised learning 11/25/13. Final project. No office hours today

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Ones Assignment Method for Solving Traveling Salesman Problem

CS 111: Program Design I Lecture 20: Web crawling, HTML, Copyright

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

n Maurice Wilkes, 1949 n Organize software to minimize errors. n Eliminate most of the errors we made anyway.

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Math Section 2.2 Polynomial Functions

Message Integrity and Hash Functions. TELE3119: Week4

CSE 417: Algorithms and Computational Complexity

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

. Written in factored form it is easy to see that the roots are 2, 2, i,

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

Guide to Applying Online

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

The isoperimetric problem on the hypercube

EE260: Digital Design, Spring /16/18. n Example: m 0 (=x 1 x 2 ) is adjacent to m 1 (=x 1 x 2 ) and m 2 (=x 1 x 2 ) but NOT m 3 (=x 1 x 2 )

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Computers and Scientific Thinking

Τεχνολογία Λογισμικού

The Magma Database file formats

1 Graph Sparsfication

Examples and Applications of Binary Search

Elementary Educational Computer

Weston Anniversary Fund

The Adjacency Matrix and The nth Eigenvalue

Parabolic Path to a Best Best-Fit Line:

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

Image Segmentation EEE 508

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only

Guide for Online Renewal

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

Designing a learning system

The number n of subintervals times the length h of subintervals gives length of interval (b-a).

IMP: Superposer Integrated Morphometrics Package Superposition Tool

Big-O Analysis. Asymptotics

One advantage that SONAR has over any other music-sequencing product I ve worked

Designing a learning system

Alpha Individual Solutions MAΘ National Convention 2013

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.

Solutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer

Our Learning Problem, Again

Analysis of Algorithms

CMSC Computer Architecture Lecture 10: Caches. Prof. Yanjing Li University of Chicago

How do we evaluate algorithms?

1.2 Binomial Coefficients and Subsets

ENGR 132. Fall Exam 1

End Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

CMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.

Mindmapping: A General Purpose (Test) Planning Tool

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

EE University of Minnesota. Midterm Exam #1. Prof. Matthew O'Keefe TA: Eric Seppanen. Department of Electrical and Computer Engineering

3D Model Retrieval Method Based on Sample Prediction

Project 2.5 Improved Euler Implementation

Creating Exact Bezier Representations of CST Shapes. David D. Marshall. California Polytechnic State University, San Luis Obispo, CA , USA

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

Making Sense of Proc Tabulate Jonas V. Bilenas, JP Morgan Chase, New York, NY

condition w i B i S maximum u i

Exercise 6 (Week 42) For the foreign students only.

GRADIENT DESCENT. Admin 10/24/13. Assignment 5. David Kauchak CS 451 Fall 2013

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

Numerical Methods Lecture 6 - Curve Fitting Techniques

MOTIF XF Extension Owner s Manual

CMSC Computer Architecture Lecture 2: ISA. Prof. Yanjing Li Department of Computer Science University of Chicago

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Package RcppRoll. December 22, 2014

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

CMSC Computer Architecture Lecture 11: More Caches. Prof. Yanjing Li University of Chicago

Transcription:

CS 111: Program Desig I Lecture #26: Heat maps, Nothig, Predictive Policig Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago November 29, 2018

Some Logistics Extra credit: Sample Fial Exam Questios Post oe good sample fial exam uestio to Piazza by the lat day of classes uder the topic sample_exam_uestio for oe poit of extra credit o the course. You will kow your uestio has bee accepted whe a professor marks it with "Good uestio" Predictive policig assigmet has bee posted to Piazza. Datasets are at lik (usig Box.com). Prof. Sloa office hours today: 3:30 5:00

HEAT MAPS

Heat map (or Heatmap) Heat map: Graphical represetatio of data where idividual values i matrix represeted as colors (Word Heatmap was coied ad trademarked i 1991)

import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5, 6] y = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0] itesity = [ [5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125], [130, 135, 140, 145, 150] ] plt.pcolor(x, y, itesity) # Creates heatmap, origi lower left corer plt.summer() # Color scheme: Gree (low) to Yellow (hi) plt.colorbar() # Adds colorbar so we kow what values mea plt.title("simple Heat Map Example")

Heat maps i Pytho Everythig we eed is i matplotlib.pyplot, so import matplotlib.plot as plt plt.pcolor(c) creates heat map from array C of color values Row 0 displayed at bottom of figure Each row displayed left to right So C[0][0] i lower left corer plt.pcolor(x, Y, C) has lists of umbers for X- ad Y-axes

Fecepost issue If you wat to specify borders of a ru of rectagles placed side-by-side, eed +1 specificatios left ed of every rectagle, ad right ed of last plt.pcolor(x, Y, C) should have le(x) = 1 + umber of colums of C le(y) = 1 + umber of rows of C I plt.pcolor(c) form labels are supplied startig at 0 for both X ad Y

Heat maps i Pytho Everythig we eed is i matplotlib.pyplot, so import matplotlib.plot as plt plt.pcolor ca take sigle array-like list of lists C as argumet, or optioally also lists X & Y givig boudaries of the rectagles plt.pcolor(c) creates heat map from array C of color values Row 0 displayed at bottom of figure Each row displayed left to right So C[0][0] i lower left corer plt.pcolor(x, Y, C) has lists of umbers for X- ad Y-axes

Fecepost issue If you wat to specify borders of a ru of rectagles placed side-by-side, eed +1 specificatios left ed of every rectagle, ad right ed of last plt.pcolor(x, Y, C) should have le(x) = 1 + umber of colums of C le(y) = 1 + umber of rows of C I plt.pcolor(c) form labels are supplied startig at 0 for both X ad Y

What do the colors mea? Colorbar plt.colorbar() places colorbar at right of plot Gives key for what colors correspod to what matrix values

Which colors i the heat map? Wat colors where huma brai uderstads idea of directio of colors. Seuetial ot raibow Bad Good Good (better?)

To set the colors ( colormap ) plt.viridis()# viridis colormap plt.summer() # summer colormap etc. Use matplotlib colormap from the Perceptually Uiform Seuetial*, Seuetial, or Seuetial(2) group *The favorite of the politically correct visualizatio police

Reasoable Colormap choices From http://matplotlib.org/examples/col or/colormaps_referece.html

import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5, 6] y = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0] itesity = [ [5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125], [130, 135, 140, 145, 150] ] plt.pcolor(x, y, itesity) plt.summer() plt.colorbar() plt.title("simple Heat Map Example")

REVIEW (?): FUNCTIONS, RETURN VALUES, NONE

Which of these is a fuctio that returs True? def A(s): if s == s: prit(true) def B(s): if s == s: retur True C: 2 i [1, 2, 3] A. A B. B C. C D. A ad B E. All of them

How cofidet are you of your aswer? A. Very Highly cofidet: I've got this B. Very cofidet C. Somewhat cofidet D. Not so cofidet: educated guess E. Not cofidet at all: radom guess ad/or bullied ito by the rest of my small group

Commo Pytho begier mistake def times3(x): y = 3 * x prit(y) # Bad! should use retur istead Caot use it as we wat to, i, e.g., to_triple = 14 tripled = times3(to_triple) prit("the result of", to_triple, " tripled is", tripled)

Why a mistake: what's coceptually wrog def times3(x): y = 3 * x prit(y) # Bad! should use retur istead Problem: It does prit value of triplig its iput but that value ot retured to place where fuctio is called!

Why mistake: what happes def times3(x): y = 3 * x prit(y) # Bad! should use retur istead >>> to_triple = 14 >>> tripled = times3(to_triple) >>> prit("the result of ", to_triple, " tripled is", tripled) The result of 14 tripled is Noe

Pytho fuctios: Nofruitful = Noe All Pytho fuctios that do ot ot have a explicit retur statemet retur Noe Noe is special Pytho value (of type NoeType) whose mai use is that it is retured automagically by fuctios that do ot execute a explicitly retur statemet with a retur value Thik of Noe as "o value" Legal to write fuctio that explicitly returs oe: retur Noe

What does the fuctio retur def mult(a, b, c): prit (a*b*c) A. Noe (o value) B. The value of a*b*c C. The strig 'a*b*c'

Nothigess cotiued a (aka NaN) is a float type missig/ull values Reuired to exist i all laguages implemetig curret stadard for float umbers (IEEE floatig poit) Ca get it explicitly as math.a ad umpy.a Comes up i padas, which uses umpy "uder the hood" Queer beasty for ay purposes but pritig/seeig math.a == math.a False

PREDICTIVE POLICING

What Is Predictive Policig? The applicatio of aalytical uatitative techiues makig statistical predictios to idetify targets for crime prevetio solve past crimes. Perry et al., Predictive Policig: The Role of Crime Forecastig i Law Eforcemet Operatios

You Ca Idetify Targets for Crime Prevetio Ward map of Chicago divided at Roosevelt Ave. Is there more crime orth or south of Roosevelt Ave.?

From The Crimes Database You Are Usig A assault is a itetioal act creatig a apprehesio immiet harmful or offesive cotact. Where would sed more police? North of Roosevelt, or South of Roosevelt? What assumptios uderlie the graph?

Crime Is Predictable There is a strog body of evidece to support the theory that crime is predictable (i the statistical sese) maily because crimials ted to operate i their comfort zoe. That is, they ted to commit the type of crimes that they have committed successfully i the past, geerally close to the same time ad locatio. Perry et al., Predictive Policig.

PredPol Usig oly three data poits crime type, crime locatio ad crime date/time PredPol s powerful software provides each law eforcemet agecy with customized crime predictios for the places ad times that crimes are most likely to occur. PredPol pipoits small areas, depicted i 500 feet by 500 feet boxes o maps that are automatically geerated for each shift of each day. The algorithms used by PredPol... are based o the observatio that certai crime types ted to cluster i time ad space. http://www.predpol.com/how-predpol-works/

Types of Predictios Predict crimes: predict places ad times with a icreased risk of crime. This is PrePol. Predict offeders: predict people at high risk for committig a future crime. Predict victims: idetify groups ad idividuals likely to become victims. Predict perpetrators: Match people with past crimes.