{ "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", " | movie_name | \n", "imdb_id | \n", "script | \n", "summary | \n", "title | \n", "year | \n", "script_plain | \n", "script_clean | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "8MM_1999 | \n", "tt0134273 | \n", "<script>\\n <scene>\\n <stage_direction>INT.... | \n", "Private investigator Tom Welles is contacted b... | \n", "8MM | \n", "1999 | \n", "\\n \\n INT. MIAMI AIRPORT, TERMINAL -- ... | \n", "INT. MIAMI AIRPORT, TERMINAL - DAY\\nAmongst th... | \n", "
1 | \n", "The Iron Lady_2011 | \n", "tt1007029 | \n", "<script>\\n <scene>\\n <stage_direction>INT.... | \n", "In flashbacks, the audience is shown a young M... | \n", "The Iron Lady | \n", "2011 | \n", "\\n \\n INT. SHOP. NR CHESTER SQUARE. LON... | \n", "INT. SHOP. NR CHESTER SQUARE. LONDON. PRESENT.... | \n", "
2 | \n", "Adventureland_2009 | \n", "tt1091722 | \n", "<script>\\n <scene>\\n <scene_description>Ad... | \n", "In 1987, James Brennan plans to have a summer ... | \n", "Adventureland | \n", "2009 | \n", "\\n \\n AdVeNtUrElAnD by Greg Mottola rev... | \n", "AdVeNtUrElAnD by Greg Mottola revised August 5... | \n", "
3 | \n", "Napoleon_2023 | \n", "tt13287846 | \n", "<script>\\n <scene>\\n <character>NAPOLEON</... | \n", "In 1793, amid the French Revolution, young arm... | \n", "Napoleon | \n", "2023 | \n", "\\n \\n NAPOLEON \\n By \\n David S... | \n", "NAPOLEON\\nBy\\nDavid Scarpa\\n\\nINT. TUILERIES -... | \n", "
4 | \n", "Kubo and the Two Strings_2016 | \n", "tt4302938 | \n", "<script>\\n <scene>\\n <character>KUBO</char... | \n", "In feudal Japan, a 12-year-old boy with only o... | \n", "Kubo and the Two Strings | \n", "2016 | \n", "\\n \\n KUBO \\n ... AND THE TWO STRIN... | \n", "KUBO\\n... AND THE TWO STRINGS\\nScreenplay by M... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2195 | \n", "Terminator Salvation_2009 | \n", "tt0438488 | \n", "<script>\\n <scene>\\n <stage_direction>INT.... | \n", "In 2003, Dr. Serena Kogan of Cyberdyne Systems... | \n", "Terminator Salvation | \n", "2009 | \n", "\\n \\n INT. DEATH ROW/CELL - DAWN \\n ... | \n", "INT. DEATH ROW/CELL - DAWN\\nLONGVIEW STATE COR... | \n", "
2196 | \n", "Collateral Damage_2002 | \n", "tt0233469 | \n", "<script>\\n <scene>\\n <stage_direction>INT.... | \n", "A bomb detonates in the plaza of the Colombian... | \n", "Collateral Damage | \n", "2002 | \n", "\\n \\n INT./EXT. NYFD FIREHOUSE - VARIOU... | \n", "INT./EXT. NYFD FIREHOUSE - VARIOUS SHOTS - NIG... | \n", "
2197 | \n", "Wonder Woman_2017 | \n", "tt0451279 | \n", "<script>\\n <scene>\\n <scene_description>FA... | \n", "In present-day Paris, Diana Prince receives a ... | \n", "Wonder Woman | \n", "2017 | \n", "\\n \\n FADE IN : \\n EXT. THE EARTH (... | \n", "FADE IN :\\nEXT. THE EARTH (FROM SPACE)\\nThe EA... | \n", "
2198 | \n", "Flatliners_2017 | \n", "tt2039338 | \n", "<script>\\n <scene>\\n <character>FLATLINERS... | \n", "Courtney is a medical student who is obsessed ... | \n", "Flatliners | \n", "2017 | \n", "\\n \\n FLATLINERS \\n By \\n Ben R... | \n", "FLATLINERS\\nBy\\nBen Ripley Based on a screenpl... | \n", "
2199 | \n", "Vacancy_2007 | \n", "tt0452702 | \n", "<script>\\n <scene>\\n <character>VACANCY</c... | \n", "On their way home from a family party, David a... | \n", "Vacancy | \n", "2007 | \n", "\\n \\n VACANCY \\n by \\n Mark L S... | \n", "VACANCY\\nby\\nMark L Smith TheHalLieberman Comp... | \n", "
2200 rows × 8 columns
\n", "