Team project "Analyzing Gender Share in Casting Actors" as part of the lecture "Data Literacy"

exp-004_Beta-Binomial-Hypothesis-Testing.ipynb 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Data Literacy - Project\n",
  8. "## Gender Share in Movies\n",
  9. "#### Tobias Stumpp, Sophia Herrmann"
  10. ]
  11. },
  12. {
  13. "cell_type": "markdown",
  14. "metadata": {},
  15. "source": [
  16. "## Beta-Binomial Hypothesis Testing"
  17. ]
  18. },
  19. {
  20. "cell_type": "markdown",
  21. "metadata": {},
  22. "source": [
  23. "### Parameters"
  24. ]
  25. },
  26. {
  27. "cell_type": "code",
  28. "execution_count": null,
  29. "metadata": {},
  30. "outputs": [],
  31. "source": [
  32. "# Starting year of the period of years covered by the test\n",
  33. "start_year = 1980\n",
  34. "# Ending year of the period of years covered by the test\n",
  35. "end_year = start_year + 40\n",
  36. "\n",
  37. "# Split year of the period of years covered by the test that separates\n",
  38. "# indicative data (>= start_year and < split_year)\n",
  39. "# from\n",
  40. "# data to be verified (>= split_year and < end_year).\n",
  41. "split_year = start_year + 20\n",
  42. "\n",
  43. "# Option to ignore movies where the average rating or the number of votes is below the respective 5% quantile.\n",
  44. "ignore_irrelevant_movies = False"
  45. ]
  46. },
  47. {
  48. "cell_type": "markdown",
  49. "metadata": {},
  50. "source": [
  51. "### Meta"
  52. ]
  53. },
  54. {
  55. "cell_type": "code",
  56. "execution_count": null,
  57. "metadata": {},
  58. "outputs": [],
  59. "source": [
  60. "import numpy as np\n",
  61. "import pandas as pd\n",
  62. "import os\n",
  63. "import matplotlib.pyplot as plt"
  64. ]
  65. },
  66. {
  67. "cell_type": "code",
  68. "execution_count": null,
  69. "metadata": {},
  70. "outputs": [],
  71. "source": [
  72. "path = '../dat/'\n",
  73. "os.chdir(path)"
  74. ]
  75. },
  76. {
  77. "cell_type": "markdown",
  78. "metadata": {},
  79. "source": [
  80. "### Read Data"
  81. ]
  82. },
  83. {
  84. "cell_type": "code",
  85. "execution_count": null,
  86. "metadata": {},
  87. "outputs": [],
  88. "source": [
  89. "columns = list(pd.read_csv('data_movie.csv', nrows=1))\n",
  90. "print(columns)"
  91. ]
  92. },
  93. {
  94. "cell_type": "code",
  95. "execution_count": null,
  96. "metadata": {},
  97. "outputs": [],
  98. "source": [
  99. "columns_to_read = [c for c in columns if c != 'genres']\n",
  100. "\n",
  101. "data_movie = pd.read_csv('data_movie.csv', usecols = columns_to_read)\n",
  102. "\n",
  103. "display(data_movie.info())\n",
  104. "display(data_movie.head())"
  105. ]
  106. },
  107. {
  108. "cell_type": "markdown",
  109. "metadata": {},
  110. "source": [
  111. "---"
  112. ]
  113. },
  114. {
  115. "cell_type": "markdown",
  116. "metadata": {},
  117. "source": [
  118. "#### Provide the option to only include movies that are relevant based on the average rating and number of votes."
  119. ]
  120. },
  121. {
  122. "cell_type": "code",
  123. "execution_count": null,
  124. "metadata": {},
  125. "outputs": [],
  126. "source": [
  127. "data_movie[['numVotes','averageRating']].describe()"
  128. ]
  129. },
  130. {
  131. "cell_type": "code",
  132. "execution_count": null,
  133. "metadata": {},
  134. "outputs": [],
  135. "source": [
  136. "numVotes_split = data_movie['numVotes'].quantile(0.05)\n",
  137. "numVotes_split"
  138. ]
  139. },
  140. {
  141. "cell_type": "code",
  142. "execution_count": null,
  143. "metadata": {},
  144. "outputs": [],
  145. "source": [
  146. "averageRating_split = data_movie['averageRating'].quantile(0.05)\n",
  147. "averageRating_split"
  148. ]
  149. },
  150. {
  151. "cell_type": "code",
  152. "execution_count": null,
  153. "metadata": {},
  154. "outputs": [],
  155. "source": [
  156. "display(data_movie.shape)"
  157. ]
  158. },
  159. {
  160. "cell_type": "code",
  161. "execution_count": null,
  162. "metadata": {},
  163. "outputs": [],
  164. "source": [
  165. "if ignore_irrelevant_movies:\n",
  166. " data_movie = data_movie[(data_movie['numVotes'] > numVotes_split) & (data_movie['averageRating'] > averageRating_split)]"
  167. ]
  168. },
  169. {
  170. "cell_type": "code",
  171. "execution_count": null,
  172. "metadata": {},
  173. "outputs": [],
  174. "source": [
  175. "display(data_movie.shape)"
  176. ]
  177. },
  178. {
  179. "cell_type": "markdown",
  180. "metadata": {},
  181. "source": [
  182. "---"
  183. ]
  184. },
  185. {
  186. "cell_type": "markdown",
  187. "metadata": {},
  188. "source": [
  189. "#### Only include the data to movies of the selected range of years."
  190. ]
  191. },
  192. {
  193. "cell_type": "code",
  194. "execution_count": null,
  195. "metadata": {},
  196. "outputs": [],
  197. "source": [
  198. "display(data_movie.shape)"
  199. ]
  200. },
  201. {
  202. "cell_type": "code",
  203. "execution_count": null,
  204. "metadata": {},
  205. "outputs": [],
  206. "source": [
  207. "data_movie = data_movie[(data_movie['startYear'] >= start_year) & (data_movie['startYear'] < end_year)]"
  208. ]
  209. },
  210. {
  211. "cell_type": "code",
  212. "execution_count": null,
  213. "metadata": {},
  214. "outputs": [],
  215. "source": [
  216. "display(data_movie.shape)"
  217. ]
  218. },
  219. {
  220. "cell_type": "markdown",
  221. "metadata": {},
  222. "source": [
  223. "### Prepare Data"
  224. ]
  225. },
  226. {
  227. "cell_type": "markdown",
  228. "metadata": {},
  229. "source": [
  230. "##### Add year span as a column"
  231. ]
  232. },
  233. {
  234. "cell_type": "code",
  235. "execution_count": null,
  236. "metadata": {},
  237. "outputs": [],
  238. "source": [
  239. "year_span_presplit = f\"{start_year}-{split_year}\"\n",
  240. "year_span_postsplit = f\"{split_year}-{end_year}\"\n",
  241. "year_span = np.where(data_movie['startYear'] < split_year, year_span_presplit, year_span_postsplit)\n",
  242. "data_movie.insert(1, 'year_span' , year_span)\n",
  243. "\n",
  244. "display(data_movie)"
  245. ]
  246. },
  247. {
  248. "cell_type": "markdown",
  249. "metadata": {},
  250. "source": [
  251. "##### Add counts and proportions on crew members"
  252. ]
  253. },
  254. {
  255. "cell_type": "code",
  256. "execution_count": null,
  257. "metadata": {},
  258. "outputs": [],
  259. "source": [
  260. "data_cast_numbers = pd.crosstab(data_movie['tconst'], data_movie['category']).reset_index().rename(columns = {\n",
  261. " 'actor':'num_actors',\n",
  262. " 'actress':'num_actresses',\n",
  263. "})\n",
  264. "\n",
  265. "data_cast_proportion = data_movie.groupby(['tconst'])['category'].value_counts(normalize=True).unstack().reset_index().fillna(0).rename(columns = {\n",
  266. " 'actor':'prop_actors',\n",
  267. " 'actress':'prop_actresses',\n",
  268. "})\n",
  269. "\n",
  270. "data_cast_gender_stat = pd.merge(data_cast_numbers, data_cast_proportion)\n",
  271. "data_cast_gender_stat"
  272. ]
  273. },
  274. {
  275. "cell_type": "code",
  276. "execution_count": null,
  277. "metadata": {},
  278. "outputs": [],
  279. "source": [
  280. "data_movie_distinct = data_movie.drop(columns=['category']).drop_duplicates(['tconst']).reset_index(drop = True)\n",
  281. "display(data_movie_distinct)\n",
  282. "\n",
  283. "data_movie_gender_stat = pd.merge(data_movie_distinct, data_cast_gender_stat)\n",
  284. "data_movie_gender_stat.groupby('year_span').apply(display)"
  285. ]
  286. },
  287. {
  288. "cell_type": "markdown",
  289. "metadata": {},
  290. "source": [
  291. "---"
  292. ]
  293. },
  294. {
  295. "cell_type": "markdown",
  296. "metadata": {},
  297. "source": [
  298. "##### Add counts on proportions of actresses relative to actors"
  299. ]
  300. },
  301. {
  302. "cell_type": "code",
  303. "execution_count": null,
  304. "metadata": {},
  305. "outputs": [],
  306. "source": [
  307. "data_movie_gender_stat['num_actresses_>_num_actors'] = (data_movie_gender_stat['num_actresses'] > data_movie_gender_stat['num_actors'])\n",
  308. "data_movie_gender_stat['num_actresses_=_num_actors'] = (data_movie_gender_stat['num_actresses'] == data_movie_gender_stat['num_actors'])\n",
  309. "data_movie_gender_stat['num_actresses_<_num_actors'] = (data_movie_gender_stat['num_actresses'] < data_movie_gender_stat['num_actors'])\n",
  310. "\n",
  311. "data_movie_gender_stat['num_actresses_=_0'] = (data_movie_gender_stat['num_actresses'] == 0)\n",
  312. "data_movie_gender_stat['num_actresses_>_0'] = (data_movie_gender_stat['num_actresses'] > 0)\n",
  313. "\n",
  314. "data_movie_gender_stat"
  315. ]
  316. },
  317. {
  318. "cell_type": "code",
  319. "execution_count": null,
  320. "metadata": {},
  321. "outputs": [],
  322. "source": [
  323. "data_actresses_stat = data_movie_gender_stat.groupby(['year_span','startYear'])[[\n",
  324. " 'num_actresses_>_num_actors',\n",
  325. " 'num_actresses_=_num_actors',\n",
  326. " 'num_actresses_<_num_actors',\n",
  327. " 'num_actresses_=_0',\n",
  328. " 'num_actresses_>_0',\n",
  329. "]].sum().reset_index()\n",
  330. "\n",
  331. "data_actresses_stat['num_movies'] = (\n",
  332. " data_actresses_stat['num_actresses_>_num_actors'] +\n",
  333. " data_actresses_stat['num_actresses_=_num_actors'] +\n",
  334. " data_actresses_stat['num_actresses_<_num_actors']\n",
  335. ")\n",
  336. "\n",
  337. "data_actresses_stat"
  338. ]
  339. },
  340. {
  341. "cell_type": "markdown",
  342. "metadata": {},
  343. "source": [
  344. "---"
  345. ]
  346. },
  347. {
  348. "cell_type": "markdown",
  349. "metadata": {},
  350. "source": [
  351. "##### Split data into their year spans"
  352. ]
  353. },
  354. {
  355. "cell_type": "code",
  356. "execution_count": null,
  357. "metadata": {},
  358. "outputs": [],
  359. "source": [
  360. "data_actresses_stat_timespan_presplit, data_actresses_stat_timespan_postsplit = [\n",
  361. " g.reset_index(drop=True) for _, g in data_actresses_stat.groupby(['year_span'])\n",
  362. "]"
  363. ]
  364. },
  365. {
  366. "cell_type": "code",
  367. "execution_count": null,
  368. "metadata": {},
  369. "outputs": [],
  370. "source": [
  371. "display(data_actresses_stat_timespan_presplit)\n",
  372. "display(data_actresses_stat_timespan_postsplit)"
  373. ]
  374. },
  375. {
  376. "cell_type": "code",
  377. "execution_count": null,
  378. "metadata": {},
  379. "outputs": [],
  380. "source": [
  381. "display(data_actresses_stat_timespan_presplit.describe())\n",
  382. "display(data_actresses_stat_timespan_postsplit.describe())"
  383. ]
  384. },
  385. {
  386. "cell_type": "markdown",
  387. "metadata": {},
  388. "source": [
  389. "---"
  390. ]
  391. },
  392. {
  393. "cell_type": "code",
  394. "execution_count": null,
  395. "metadata": {},
  396. "outputs": [],
  397. "source": [
  398. "data_actresses_stat_sum = data_actresses_stat.drop(columns=['startYear']).groupby(['year_span']).sum()\n",
  399. "data_actresses_stat_sum"
  400. ]
  401. },
  402. {
  403. "cell_type": "markdown",
  404. "metadata": {},
  405. "source": [
  406. "---"
  407. ]
  408. },
  409. {
  410. "cell_type": "markdown",
  411. "metadata": {},
  412. "source": [
  413. "### Analyze Data"
  414. ]
  415. },
  416. {
  417. "cell_type": "markdown",
  418. "metadata": {},
  419. "source": [
  420. "#### Compute p-Values\n",
  421. "\n",
  422. "Our goal is to find out if actresses achieved significantly more movies with *majority shares* or less movies with *minority shares* in the principal casts after the split year than before the split year. \n",
  423. "We perform a beta-binomial test and explicitly follow the example presented in the lecture and exercise on scores of the German Bundesliga."
  424. ]
  425. },
  426. {
  427. "cell_type": "markdown",
  428. "metadata": {},
  429. "source": [
  430. "- First, we put a beta-prior on $f_0$ (the majority probability before the split year) which is based on $m_0$ (the number of movies with majority share before the split year) in $n_0$ movies (the number of movies before the split year).\n",
  431. "\n",
  432. "- Under the null hypothesis $H_0: f_1 = f_0$, the number of movies with majority share after the split year $m_1$ (given the number of movies after the split year $n_1$) follows a binomial distribution. \n",
  433. "\n",
  434. "- Putting these building blocks together, we obtain a [beta-binomial distribution](https://en.wikipedia.org/wiki/Beta-binomial_distribution)\n",
  435. "\n",
  436. " \\begin{equation}\n",
  437. " p(m_1 \\vert n_1, m_0, n_0) \n",
  438. " = {n_1\\choose m_1} \n",
  439. " \\frac{\\mathcal{B}(m_0 + m_1 + 1, (n_0-m_0) + (n_1-m_1) + 1)}\n",
  440. " {\\mathcal{B}(m_0 + 1, n_0 - m_0 + 1)}.\n",
  441. " \\end{equation}\n",
  442. "\n",
  443. " This tells us the probability to observe $m_1$ for movies with *majority shares* after the split year, given the number of movies after the split year $n_1$ and the statistics $m_0$, $n_0$ for the years before."
  444. ]
  445. },
  446. {
  447. "cell_type": "code",
  448. "execution_count": null,
  449. "metadata": {},
  450. "outputs": [],
  451. "source": [
  452. "from scipy.stats import betabinom"
  453. ]
  454. },
  455. {
  456. "cell_type": "code",
  457. "execution_count": null,
  458. "metadata": {},
  459. "outputs": [],
  460. "source": [
  461. "def p_val_won(m_1, n_1, m_0, n_0):\n",
  462. " \"\"\"\n",
  463. " Compute p-value by summing the evidence p(m_1 | n_1, m_0, n_0) over the \n",
  464. " observed number of won movies and 'more extreme' (i.e. smaller) movie counts.\n",
  465. " \n",
  466. " Parameters\n",
  467. " ----------\n",
  468. " m_1 : int\n",
  469. " Number of won movies after the split year (0 <= m_1 <= n_1)\n",
  470. " n_1 : int\n",
  471. " Number of movies after the split year (n_1 > 0)\n",
  472. " m_0 : int\n",
  473. " Number of won movies before the split year (0 <= m_0 <= n_0)\n",
  474. " n_0 : int\n",
  475. " Number of movies before the split year (n_0 > 0)\n",
  476. " \n",
  477. " Result\n",
  478. " ------\n",
  479. " The probability for observing m_1 or less movies.\n",
  480. " \"\"\"\n",
  481. " return betabinom.cdf(m_1, n_1, m_0 + 1, n_0 - m_0 + 1)"
  482. ]
  483. },
  484. {
  485. "cell_type": "code",
  486. "execution_count": null,
  487. "metadata": {},
  488. "outputs": [],
  489. "source": [
  490. "def p_val_lost(m_1, n_1, m_0, n_0):\n",
  491. " \"\"\"\n",
  492. " Compute p-value by summing the evidence p(m_1 | n_1, m_0, n_0) over the \n",
  493. " observed number of lost movies and 'more extreme' (i.e. larger) movie counts.\n",
  494. " \n",
  495. " Parameters\n",
  496. " ----------\n",
  497. " m_1 : int\n",
  498. " Number of lost movies after the split year (0 <= m_1 <= n_1)\n",
  499. " n_1 : int\n",
  500. " Number of movies after the split year (n_1 > 0)\n",
  501. " m_0 : int\n",
  502. " Number of lost movies before the split year (0 <= m_0 <= n_0)\n",
  503. " n_0 : int\n",
  504. " Number of movies before the split year (n_0 > 0)\n",
  505. " \n",
  506. " Result\n",
  507. " ------\n",
  508. " The probability for observing m_1 or more movies.\n",
  509. " \"\"\"\n",
  510. " return 1.0 - betabinom.cdf(m_1 - 1, n_1, m_0 + 1, n_0 - m_0 + 1)"
  511. ]
  512. },
  513. {
  514. "cell_type": "code",
  515. "execution_count": null,
  516. "metadata": {},
  517. "outputs": [],
  518. "source": [
  519. "def print_result(p_val):\n",
  520. " alpha = 0.05\n",
  521. " # Significant results?\n",
  522. " print(f\"{'Yes' if (p_val <= alpha) else 'No'}, the result is {'significant' if (p_val <= alpha) else 'insignificant'} because given the pre-split-year data, observing the post-split-year data has a {p_val*100:.2f}% probability.\")"
  523. ]
  524. },
  525. {
  526. "cell_type": "markdown",
  527. "metadata": {},
  528. "source": [
  529. "#### Are there more movies with a majority of actresses in the principal roles?"
  530. ]
  531. },
  532. {
  533. "cell_type": "code",
  534. "execution_count": null,
  535. "metadata": {},
  536. "outputs": [],
  537. "source": [
  538. "p_val_actresses_in_majority = p_val_lost(\n",
  539. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_>_num_actors'], # <---\n",
  540. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  541. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_>_num_actors'], # <---\n",
  542. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  543. ")\n",
  544. "\n",
  545. "print_result(p_val_actresses_in_majority)"
  546. ]
  547. },
  548. {
  549. "cell_type": "markdown",
  550. "metadata": {},
  551. "source": [
  552. "#### Are there less movies with a minority of actresses in the principal roles?"
  553. ]
  554. },
  555. {
  556. "cell_type": "code",
  557. "execution_count": null,
  558. "metadata": {},
  559. "outputs": [],
  560. "source": [
  561. "p_val_actresses_in_minority = p_val_won(\n",
  562. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_<_num_actors'], # <---\n",
  563. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  564. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_<_num_actors'], # <---\n",
  565. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  566. ")\n",
  567. "\n",
  568. "print_result(p_val_actresses_in_minority)"
  569. ]
  570. },
  571. {
  572. "cell_type": "markdown",
  573. "metadata": {},
  574. "source": [
  575. "#### Are there less movies with a majority of actresses in the principal roles?"
  576. ]
  577. },
  578. {
  579. "cell_type": "code",
  580. "execution_count": null,
  581. "metadata": {},
  582. "outputs": [],
  583. "source": [
  584. "p_val_actresses_in_majority = p_val_won(\n",
  585. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_>_num_actors'], # <---\n",
  586. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  587. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_>_num_actors'], # <---\n",
  588. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  589. ")\n",
  590. "\n",
  591. "print_result(p_val_actresses_in_majority)"
  592. ]
  593. },
  594. {
  595. "cell_type": "markdown",
  596. "metadata": {},
  597. "source": [
  598. "#### Are there more movies with a minority of actresses in the principal roles?"
  599. ]
  600. },
  601. {
  602. "cell_type": "code",
  603. "execution_count": null,
  604. "metadata": {},
  605. "outputs": [],
  606. "source": [
  607. "p_val_actresses_in_minority = p_val_lost(\n",
  608. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_<_num_actors'], # <---\n",
  609. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  610. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_<_num_actors'], # <---\n",
  611. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  612. ")\n",
  613. "\n",
  614. "print_result(p_val_actresses_in_minority)"
  615. ]
  616. },
  617. {
  618. "cell_type": "markdown",
  619. "metadata": {},
  620. "source": [
  621. "---"
  622. ]
  623. },
  624. {
  625. "cell_type": "markdown",
  626. "metadata": {},
  627. "source": [
  628. "#### Are there less movies with zero actresses in the principal roles?"
  629. ]
  630. },
  631. {
  632. "cell_type": "code",
  633. "execution_count": null,
  634. "metadata": {},
  635. "outputs": [],
  636. "source": [
  637. "p_val_actresses_eq_zero = p_val_won(\n",
  638. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_=_0'], # <---\n",
  639. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  640. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_=_0'], # <---\n",
  641. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  642. ")\n",
  643. "\n",
  644. "print_result(p_val_actresses_eq_zero)"
  645. ]
  646. },
  647. {
  648. "cell_type": "markdown",
  649. "metadata": {},
  650. "source": [
  651. "#### Are there more movies with more than zero actresses in the principal roles?"
  652. ]
  653. },
  654. {
  655. "cell_type": "code",
  656. "execution_count": null,
  657. "metadata": {},
  658. "outputs": [],
  659. "source": [
  660. "p_val_actresses_gt_zero = p_val_lost(\n",
  661. " data_actresses_stat_sum.loc[year_span_postsplit,'num_actresses_>_0'], # <---\n",
  662. " data_actresses_stat_sum.loc[year_span_postsplit,'num_movies'],\n",
  663. " data_actresses_stat_sum.loc[year_span_presplit, 'num_actresses_>_0'], # <---\n",
  664. " data_actresses_stat_sum.loc[year_span_presplit, 'num_movies'],\n",
  665. ")\n",
  666. "\n",
  667. "print_result(p_val_actresses_gt_zero)"
  668. ]
  669. },
  670. {
  671. "cell_type": "markdown",
  672. "metadata": {},
  673. "source": [
  674. "### Results"
  675. ]
  676. },
  677. {
  678. "cell_type": "markdown",
  679. "metadata": {},
  680. "source": [
  681. "In summary, the series on the beta-binomial test shows that there are more films with a majority of actresses and fewer films with a minority of actresses in the lead roles. \n",
  682. "The rest of the tests with this test did not show significance.\n",
  683. "\n",
  684. "We interpret the results overall as an indicator of improvement in the proportion of principal actresses.\n",
  685. "\n",
  686. "Note: It is difficult for us to evaluate how reliable these results are. On the one hand, we've learned about the test method on a close example in the lecture and we are convinced that we can apply this model to this movie cast data, on the other hand, we don't know how meaningful this result imposes on the ratio of actors and actresses, despite the striking low p-values."
  687. ]
  688. }
  689. ],
  690. "metadata": {
  691. "kernelspec": {
  692. "display_name": "Python 3",
  693. "language": "python",
  694. "name": "python3"
  695. },
  696. "language_info": {
  697. "codemirror_mode": {
  698. "name": "ipython",
  699. "version": 3
  700. },
  701. "file_extension": ".py",
  702. "mimetype": "text/x-python",
  703. "name": "python",
  704. "nbconvert_exporter": "python",
  705. "pygments_lexer": "ipython3",
  706. "version": "3.8.8"
  707. }
  708. },
  709. "nbformat": 4,
  710. "nbformat_minor": 4
  711. }

Powered by TurnKey Linux.