Problem 1: Plotting the Club Members For this problem, i need to…
Question Problem 1: Plotting the Club Members For this problem, i need to… Problem 1: Plotting the Club Members For this problem, i need to plot the data scientists in the data-science club so that we can conveniently visualize their tenured years, salaries, and paid accounts or not. Note that this problem was approached in an earlier assignment. I expect to explore the data by approaching the question. the solution to problem #1 import numpy as np import pandas as pd import seaborn as snsimport matplotlib.pyplot as plt?data = np.array([(0.7,48000,1),(1.9,48000,0),(2.5,60000,1),(4.2,63000,0),(6,76000,0),(6.5,69000,0),(7.5,76000,0),(8.1,88000,0),(8.7,83000,1),(10,83000,1),(0.8,43000,0),(1.8,60000,0),(10,79000,1),(6.1,76000,0),(1.4,50000,0),(9.1,92000,0),(5.8,75000,0),(5.2,69000,0),(1,56000,0),(6,67000,0),(4.9,74000,0),(6.4,63000,1),(6.2,82000,0),(3.3,58000,0),(9.3,90000,1),(5.5,57000,1),(9.1,102000,0),(2.4,54000,0),(8.2,65000,1),(5.3,82000,0),(9.8,107000,0),(1.8,64000,0),(0.6,46000,1),(0.8,48000,0),(8.6,84000,1),(0.6,45000,0),(0.5,30000,1),(7.3,89000,0),(2.5,48000,1),(5.6,76000,0),(7.4,77000,0),(2.7,56000,0),(0.7,48000,0),(1.2,42000,0),(0.2,32000,1),(4.7,56000,1),(2.8,44000,1),(7.6,78000,0),(1.1,63000,0),(8,79000,1),(2.7,56000,0),(6,52000,1),(4.6,56000,0),(2.5,51000,0),(5.7,71000,0),(2.9,65000,0),(1.1,33000,1),(3,62000,0),(4,71000,0),(2.4,61000,0),(7.5,75000,0),(9.7,81000,1),(3.2,62000,0),(7.9,88000,0),(4.7,44000,1),(2.5,55000,0),(1.6,41000,0),(6.7,64000,1),(6.9,66000,1),(7.9,78000,1),(8.1,102000,0),(5.3,48000,1),(8.5,66000,1),(0.2,56000,0),(6,69000,0),(7.5,77000,0),(8,86000,0),(4.4,68000,0),(4.9,75000,0),(1.5,60000,0),(2.2,50000,0),(3.4,49000,1),(4.2,70000,0),(7.7,98000,0),(8.2,85000,0),(5.4,88000,0),(0.1,46000,0),(1.5,37000,0),(6.3,86000,0),(3.7,57000,0),(8.4,85000,0),(2,42000,0),(5.8,69000,1),(2.7,64000,0),(3.1,63000,0),(1.9,48000,0),(10,72000,1),(0.2,45000,0),(8.6,95000,0),(1.5,64000,0),(9.8,95000,0),(5.3,65000,0),(7.5,80000,0),(9.9,91000,0),(9.7,50000,1),(2.8,68000,0),(3.6,58000,0),(3.9,74000,0),(4.4,76000,0),(2.5,49000,0),(7.2,81000,0),(5.2,60000,1),(2.4,62000,0),(8.9,94000,0),(2.4,63000,0),(6.8,69000,1),(6.5,77000,0),(7,86000,0),(9.4,94000,0),(7.8,72000,1),(0.2,53000,0),(10,97000,0),(5.5,65000,0),(7.7,71000,1),(8.1,66000,1),(9.8,91000,0),(8,84000,0),(2.7,55000,0),(2.8,62000,0),(9.4,79000,0),(2.5,57000,0),(7.4,70000,1),(2.1,47000,0),(5.3,62000,1),(6.3,79000,0),(6.8,58000,1),(5.7,80000,0),(2.2,61000,0),(4.8,62000,0),(3.7,64000,0),(4.1,85000,0),(2.3,51000,0),(3.5,58000,0),(0.9,43000,0),(0.9,54000,0),(4.5,74000,0),(6.5,55000,1),(4.1,41000,1),(7.1,73000,0),(1.1,66000,0),(9.1,81000,1),(8,69000,1),(7.3,72000,1),(3.3,50000,0),(3.9,58000,0),(2.6,49000,0),(1.6,78000,0),(0.7,56000,0),(2.1,36000,1),(7.5,90000,0),(4.8,59000,1),(8.9,95000,0),(6.2,72000,0),(6.3,63000,0),(9.1,100000,0),(7.3,61000,1),(5.6,74000,0),(0.5,66000,0),(1.1,59000,0),(5.1,61000,0),(6.2,70000,0),(6.6,56000,1),(6.3,76000,0),(6.5,78000,0),(5.1,59000,0),(9.5,74000,1),(4.5,64000,0),(2,54000,0),(1,52000,0),(4,69000,0),(6.5,76000,0),(3,60000,0),(4.5,63000,0),(7.8,70000,0),(3.9,60000,1),(0.8,51000,0),(4.2,78000,0),(1.1,54000,0),(6.2,60000,0),(2.9,59000,0),(2.1,52000,0),(8.2,87000,0),(4.8,73000,0),(2.2,42000,1),(9.1,98000,0),(6.5,84000,0),(6.9,73000,0),(5.1,72000,0),(9.1,69000,1),(9.8,79000,1),])?data_df = pd.DataFrame(data)data_df.columns = [‘tenure years’,’salaries’,’account status’]#used to help decide what what the best visualization tool#sns.pairplot(data_df)??#we will plot and “convieneniently visualize”df = data_df.sort_values(by=[‘tenure years’],ascending=True)plt.plot(df[‘tenure years’],df[‘salaries’])plt.show() ### Problem 3 Logistic RegressionIn this problem, I need to write function(s) to build a classifier using a logistic regression algorithm. Then, you need to apply the test methods (leave one out and randomSplit) to evaluate the learned classifier in terms of accuracy, sensitivity, specificity, and positive predictive value.The output of your evaluation on the logistic-regression classifier you built could be similar to the below, assuming the salary and tenured year values are scaled to values that have mean 0 and std 1. The next code cell copies the function scaleAttr we studied in lectures.“`Average of 10 80/20 splits LRAccuracy = 0.863Sensitivity = 0.604Specificity = 0.95Pos. Pred. Val. = 0.803Average of LOO testing using LRAccuracy = 0.875Sensitivity = 0.615Specificity = 0.966Pos. Pred. Val. = 0.865“`Additionally, you need to plot the ROC curve and compute the AUC score to evaluate your classifier. sample code: “#z-scaling. The returned array should have mean 0 and std 1#def scaleAttrs(vals):# vals = np.array(vals) # mean = sum(vals)/len(vals) # sd = np.std(vals) #vals = vals – mean #return vals/sd” the file that should be used is “loan_data.csv”.id,outcome,dti,borrower_score,payment_inc_ratio32109,paid off,21.23,0.4,5.1113516982,default,15.49,0.4,5.4316525335,paid off,27.3,0.7,9.23003000000000134580,paid off,21.11,0.4,2.3348214424,default,16.46,0.45,12.103235621,paid off,12.12,0.5,3.893919920,default,29.79,0.4,7.003942095,paid off,7.94,0.4,10.040725219,paid off,10.81,0.55,3.549719999999999826196,paid off,16.37,0.45,7.5098419798,default,11.42,0.4,1.820609999999999835333,paid off,7.22,0.6,11.179433036,paid off,12.95,0.45,3.16522999999999986729,default,14.79,0.5,2.4237140734,paid off,16.75,0.75,3.90433148,paid off,25.71,0.75,9.106386707,default,22.37,0.3,8.2544331,paid off,17.73,0.65,7.0831629681,paid off,21.78,0.45,8.9487800000000019141,default,8.18,0.7,8.3977518112,default,11.52,0.6,11.471318492,default,21.7,0.45,9.32833000000000138079,paid off,18.67,0.6,2.4043522712,default,33.32,0.25,15.52519911,default,23.37,0.45,9.093145042,default,21.63,0.55,10.22285968,default,25.0,0.35,12.8354550,default,16.57,0.4,3.8220530075,paid off,18.62,0.55,10.736242738,paid off,14.25,0.4,8.200517209,default,25.74,0.55,13.855417292,default,21.16,0.4,10.41256062,default,10.0,0.5,3.59956457,default,14.19,0.6,6.8213300000000011461,default,15.4,0.45,8.225637195,default,13.76,0.5,9.8815542207,paid off,14.76,0.65,2.84045953,default,18.62,0.5,7.0396511388,default,6.82,0.4,10.625914956,default,13.74,0.65,5.1508534666,paid off,8.52,0.45,10.145235707,paid off,10.91,0.55,8.15486000000000117656,default,15.42,0.3,10.301614227,default,20.62,0.45,4.540741294,paid off,12.74,0.3,5.83543000000000130323,paid off,7.41,0.55,5.459519999999999539802,paid off,4.8,0.2,5.0835727950,paid off,11.47,0.25,3.940740000000000438596,paid off,10.43,0.8,3.4660422035,default,13.38,0.45,8.5027117634,default,19.35,0.3,2.988823441,default,10.1,0.4,6.693954647,default,20.37,0.35,3.375171263,default,16.94,0.35,6.678339999999999537283,paid off,4.9,0.55,2.5454720048,default,12.71,0.5,5.199240000000000531673,paid off,0.62,0.65,4.1204531412,paid off,13.15,0.55,5.7261337980,paid off,14.92,0.45,5.05333629,default,22.71,0.45,7.848582,default,12.9,0.45,4.2671644344,paid off,4.0,0.65,3.078521662,default,32.4,0.6,11.235227179,paid off,12.78,0.5,3.754911060,default,17.12,0.35,14.348322210,default,16.06,0.7,4.08124095,default,19.72,0.4,17.985630270,paid off,15.17,0.4,7.329744976,paid off,15.94,0.5,6.8433899999999996117,default,14.28,0.55,6.345709999999999524695,paid off,14.64,0.75,5.2177736045,paid off,8.45,0.4,5.3613930548,paid off,20.79,0.7,6.6990520962,default,7.14,0.55,9.4267127,default,22.17,0.55,5.499309999999999534943,paid off,10.19,0.45,2.346833042,paid off,17.18,0.6,3.913999999999999729231,paid off,18.6,0.6,7.76373000000000142989,paid off,20.89,0.55,6.3273432224,paid off,12.89,0.55,8.85640177,paid off,15.95,0.55,9.871714402,default,1.77,0.35,0.22190623386,paid off,17.0,0.55,6.4373527429,paid off,13.06,0.5,9.7206936110,paid off,25.38,0.3,7.808289999999999511471,default,22.83,0.5,17.80675786,default,22.47,0.65,1.560198501,default,11.64,0.6,13.677632345,paid off,13.91,0.7,2.3222940814,paid off,29.97,0.55,14.7331506,paid off,25.42,0.75,5.7741522071,default,27.5,0.6,14.70038760,default,18.72,0.5,6.89329467,default,15.41,0.5,12.80436089,paid off,20.96,0.7,9.011688824,default,29.07,0.3,15.021936871,paid off,14.92,0.7,3.311819999999999515016,default,15.33,0.65,10.908427811,paid off,15.69,0.4,1.640759999999999831477,paid off,0.6,0.6,5.996716443,default,8.95,0.55,5.8278927974,paid off,5.61,0.6,3.5689532565,paid off,25.41,0.6,13.30635276,default,1.57,0.35,9.586089853,default,19.11,0.45,2.37579597,default,30.6,0.45,15.675229012,paid off,12.53,0.6,2.075637993,default,25.23,0.75,12.976414378,default,24.82,0.35,10.548722808,default,21.91,0.5,5.06023000000000122378,default,13.03,0.6,11.1843700,default,13.65,0.55,14.80869022,default,7.75,0.7,9.547432061,paid off,8.02,0.7,8.98299999999999917635,default,16.71,0.5,8.647942782,default,15.14,0.35,12.76535404,paid off,4.86,0.7,1.8697241582,paid off,30.18,0.5,8.7412545473,paid off,15.51,0.55,1.4085228218,paid off,23.25,0.45,2.8957732473,paid off,8.42,0.35,5.3621844026,paid off,9.06,0.4,16.35386893,default,26.13,0.35,9.9349331532,paid off,18.08,0.5,5.1222645242,paid off,22.42,0.45,4.421440000000000544608,paid off,1.53,0.85,9.12638999999999946149,paid off,10.34,0.55,9.5913241086,paid off,3.27,0.7,2.380838554,paid off,8.36,0.75,10.594622948,default,9.36,0.55,12.84223380,paid off,4.8,0.65,2.646340000000000435870,paid off,15.62,0.6,2.7439125168,paid off,19.82,0.4,1.199433438,paid off,12.85,0.5,5.195130000000001118,default,20.25,0.35,9.5201523072,default,18.89,0.7,10.478611667,default,11.42,0.4,5.844824474,paid off,26.7,0.5,4.0560800000000017052,default,30.49,0.5,15.21057909,default,28.54,0.55,12.24923968,paid off,17.28,0.45,9.73951999999999923970,paid off,20.95,0.55,6.9281545544,paid off,14.84,0.45,10.4985155,default,6.6,0.65,2.34770999999999972403,default,20.35,0.3,7.00433999999999924451,paid off,16.44,0.4,5.839517843,default,24.53,0.65,8.2398120308,default,5.31,0.65,13.859146046,paid off,22.25,0.45,15.353113194,default,32.47,0.55,14.15737193,default,20.4,0.4,13.486345182,paid off,4.17,0.5,11.816729329,paid off,15.4,0.45,9.3894531861,paid off,21.26,0.55,6.3214834326,paid off,11.96,0.8,5.715633876,paid off,10.26,0.35,8.68414688,default,18.07,0.45,13.786339274,paid off,34.22,0.45,6.1823830852,paid off,20.78,0.45,12.873535749,paid off,9.95,0.65,4.93873000000000056168,default,31.44,0.3,8.759716500,default,14.19,0.35,14.246732488,paid off,5.8,0.6,13.907333946,paid off,27.03,0.35,13.097839607,paid off,26.94,0.35,9.4432922499,default,24.53,0.45,9.3243577,default,16.62,0.55,1.022191272,default,18.23,0.35,9.34686000000000129795,paid off,8.48,0.65,13.537815342,default,31.47,0.25,5.763310198,default,30.21,0.55,14.96619339,default,13.05,0.45,2.988709999999999819368,default,25.68,0.6,5.59597316,default,20.08,0.4,11.715613922,default,9.41,0.45,18.71116124,default,20.18,0.35,5.3720742829,paid off,25.11,0.65,3.551030000000000436381,paid off,17.88,0.7,8.25630059,paid off,28.68,0.6,10.885742055,paid off,19.9,0.6,8.35773 (there is a lot more data, really only need question 3 answered) Computer Science Engineering & Technology Python Programming APCV 361 Share QuestionEmailCopy link Comments (0)


