Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am getting an error when trying to execute the following problem and code. In PYTHON and PANDAS cramers_v function Q 14 (.5 points)

Hello, I am getting an error when trying to execute the following problem and code.

In PYTHON and PANDAS

image text in transcribed

cramers_v function

image text in transcribed

Q 14 (.5 points) Using pandas cross tabulate Survived and Title in titanic_df_small. Also compute cramers_v for association between Survived and Title. In [27]: 1 from IPython.display import display 2 3 ct = pd.crosstab(index=titanic_df_small('Title'], columns=titanic_df_small('Survived']) 4 5 display(ct) 6 7 ct.apply(cramers_v) Survived 0 1 Title Master. 17 23 Miss. 55 126 Mr. 436 81 Mrs. 26 98 : 1 def cramers_v(confusion_matrix) : 2 "' calculate Cramers V statistic for categorial-categorial association. 3 uses correction from Bergsma and Wicher, 4 Journal of the Korean Statistical Society 42 (2013): 323-328 5 6 chi2 = ss.chi2_contingency(confusion_matrix)[0] 7 n = confusion_matrix.sum() 8 phi2 = chi2 / n 9 r, k = confusion_matrix.shape 10 phi2corr = max(0, phi2 - ((k-1)*(r-1))/(n-1)) 11 rcorr = r - ((r-1)**2)/(n-1) 12 kcorr = k - ((k-1)**2)/(n-1) 13 return np.sqrt(phi2corr / min((kcorr-1), (rcorr-1)))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions