{ "cells": [ { "cell_type": "markdown", "id": "fafe2f02-0f95-4f44-b272-59466084cfe4", "metadata": {}, "source": [ "**Predicting Oscar-Nominated Screenplays with Sentence Embeddings**\n", "\n", "Francis Gross \n", "Faculty of Informatics and Data Science \n", "University of Regensburg \n", "93053 Regensburg, Germany \n", "francis.gross@stud.uni-regensburg.de" ] }, { "cell_type": "code", "execution_count": 78, "id": "c2b3edc6-d38a-4f38-9862-fdee52e95f5a", "metadata": {}, "outputs": [], "source": [ "# import:\n", "\n", "import pandas as pd\n", "import re, numpy as np\n", "import unicodedata\n", "import joblib\n", "import torch\n", "\n", "from pathlib import Path\n", "from datasets import load_dataset\n", "from sklearn.model_selection import train_test_split\n", "from tqdm import tqdm\n", "from sentence_transformers import SentenceTransformer\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.metrics import f1_score, accuracy_score, roc_auc_score, average_precision_score" ] }, { "cell_type": "code", "execution_count": 79, "id": "063b63d8-0d34-459f-8f60-b678edcc02ca", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Repo card metadata block was not found. Setting CardData to empty.\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
movie_nameimdb_idscriptsummarytitleyearscript_plainscript_clean
08MM_1999tt0134273<script>\\n <scene>\\n <stage_direction>INT....Private investigator Tom Welles is contacted b...8MM1999\\n \\n INT. MIAMI AIRPORT, TERMINAL -- ...INT. MIAMI AIRPORT, TERMINAL - DAY\\nAmongst th...
1The Iron Lady_2011tt1007029<script>\\n <scene>\\n <stage_direction>INT....In flashbacks, the audience is shown a young M...The Iron Lady2011\\n \\n INT. SHOP. NR CHESTER SQUARE. LON...INT. SHOP. NR CHESTER SQUARE. LONDON. PRESENT....
2Adventureland_2009tt1091722<script>\\n <scene>\\n <scene_description>Ad...In 1987, James Brennan plans to have a summer ...Adventureland2009\\n \\n AdVeNtUrElAnD by Greg Mottola rev...AdVeNtUrElAnD by Greg Mottola revised August 5...
3Napoleon_2023tt13287846<script>\\n <scene>\\n <character>NAPOLEON</...In 1793, amid the French Revolution, young arm...Napoleon2023\\n \\n NAPOLEON \\n By \\n David S...NAPOLEON\\nBy\\nDavid Scarpa\\n\\nINT. TUILERIES -...
4Kubo and the Two Strings_2016tt4302938<script>\\n <scene>\\n <character>KUBO</char...In feudal Japan, a 12-year-old boy with only o...Kubo and the Two Strings2016\\n \\n KUBO \\n ... AND THE TWO STRIN...KUBO\\n... AND THE TWO STRINGS\\nScreenplay by M...
...........................
2195Terminator Salvation_2009tt0438488<script>\\n <scene>\\n <stage_direction>INT....In 2003, Dr. Serena Kogan of Cyberdyne Systems...Terminator Salvation2009\\n \\n INT. DEATH ROW/CELL - DAWN \\n ...INT. DEATH ROW/CELL - DAWN\\nLONGVIEW STATE COR...
2196Collateral Damage_2002tt0233469<script>\\n <scene>\\n <stage_direction>INT....A bomb detonates in the plaza of the Colombian...Collateral Damage2002\\n \\n INT./EXT. NYFD FIREHOUSE - VARIOU...INT./EXT. NYFD FIREHOUSE - VARIOUS SHOTS - NIG...
2197Wonder Woman_2017tt0451279<script>\\n <scene>\\n <scene_description>FA...In present-day Paris, Diana Prince receives a ...Wonder Woman2017\\n \\n FADE IN : \\n EXT. THE EARTH (...FADE IN :\\nEXT. THE EARTH (FROM SPACE)\\nThe EA...
2198Flatliners_2017tt2039338<script>\\n <scene>\\n <character>FLATLINERS...Courtney is a medical student who is obsessed ...Flatliners2017\\n \\n FLATLINERS \\n By \\n Ben R...FLATLINERS\\nBy\\nBen Ripley Based on a screenpl...
2199Vacancy_2007tt0452702<script>\\n <scene>\\n <character>VACANCY</c...On their way home from a family party, David a...Vacancy2007\\n \\n VACANCY \\n by \\n Mark L S...VACANCY\\nby\\nMark L Smith TheHalLieberman Comp...
\n", "

2200 rows × 8 columns

\n", "
" ], "text/plain": [ " movie_name imdb_id \\\n", "0 8MM_1999 tt0134273 \n", "1 The Iron Lady_2011 tt1007029 \n", "2 Adventureland_2009 tt1091722 \n", "3 Napoleon_2023 tt13287846 \n", "4 Kubo and the Two Strings_2016 tt4302938 \n", "... ... ... \n", "2195 Terminator Salvation_2009 tt0438488 \n", "2196 Collateral Damage_2002 tt0233469 \n", "2197 Wonder Woman_2017 tt0451279 \n", "2198 Flatliners_2017 tt2039338 \n", "2199 Vacancy_2007 tt0452702 \n", "\n", " script \\\n", "0