AliZain1's picture
Update app.py
d552f0e verified
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"None","dataSources":[{"sourceType":"datasetVersion","sourceId":9375511,"datasetId":3816617,"databundleVersionId":9575818}],"dockerImageVersionId":30761,"isInternetEnabled":True,"language":"python","sourceType":"notebook","isGpuEnabled":False}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n for filename in filenames:\n print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-09-12T13:59:21.117080Z","iopub.execute_input":"2024-09-12T13:59:21.118163Z","iopub.status.idle":"2024-09-12T13:59:21.575338Z","shell.execute_reply.started":"2024-09-12T13:59:21.118087Z","shell.execute_reply":"2024-09-12T13:59:21.574006Z"},"trusted":True},"execution_count":1,"outputs":[{"name":"stdout","text":"/kaggle/input/tmdb-movies-dataset-2023-930k-movies/TMDB_movie_dataset_v11.csv\n","output_type":"stream"}]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:21.577852Z","iopub.execute_input":"2024-09-12T13:59:21.578449Z","iopub.status.idle":"2024-09-12T13:59:23.377528Z","shell.execute_reply.started":"2024-09-12T13:59:21.578400Z","shell.execute_reply":"2024-09-12T13:59:23.376274Z"},"trusted":True},"execution_count":2,"outputs":[]},{"cell_type":"code","source":"main_df = pd.read_csv('/kaggle/input/tmdb-movies-dataset-2023-930k-movies/TMDB_movie_dataset_v11.csv')","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:23.379255Z","iopub.execute_input":"2024-09-12T13:59:23.380173Z","iopub.status.idle":"2024-09-12T13:59:43.297257Z","shell.execute_reply.started":"2024-09-12T13:59:23.380095Z","shell.execute_reply":"2024-09-12T13:59:43.295964Z"},"trusted":True},"execution_count":3,"outputs":[]},{"cell_type":"code","source":"df = main_df[main_df['vote_average']!=0]","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.299813Z","iopub.execute_input":"2024-09-12T13:59:43.300233Z","iopub.status.idle":"2024-09-12T13:59:43.410857Z","shell.execute_reply.started":"2024-09-12T13:59:43.300192Z","shell.execute_reply":"2024-09-12T13:59:43.409226Z"},"trusted":True},"execution_count":4,"outputs":[]},{"cell_type":"code","source":"df.reset_index(inplace=True)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.412601Z","iopub.execute_input":"2024-09-12T13:59:43.413707Z","iopub.status.idle":"2024-09-12T13:59:43.422433Z","shell.execute_reply.started":"2024-09-12T13:59:43.413646Z","shell.execute_reply":"2024-09-12T13:59:43.421328Z"},"trusted":True},"execution_count":5,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.423990Z","iopub.execute_input":"2024-09-12T13:59:43.424908Z","iopub.status.idle":"2024-09-12T13:59:43.437036Z","shell.execute_reply.started":"2024-09-12T13:59:43.424856Z","shell.execute_reply":"2024-09-12T13:59:43.435582Z"},"trusted":True},"execution_count":6,"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"(349038, 25)"},"metadata":{}}]},{"cell_type":"markdown","source":"# Features Selection","metadata":{}},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.438401Z","iopub.execute_input":"2024-09-12T13:59:43.438777Z","iopub.status.idle":"2024-09-12T13:59:43.453587Z","shell.execute_reply.started":"2024-09-12T13:59:43.438739Z","shell.execute_reply":"2024-09-12T13:59:43.452347Z"},"trusted":True},"execution_count":7,"outputs":[{"execution_count":7,"output_type":"execute_result","data":{"text/plain":"Index(['index', 'id', 'title', 'vote_average', 'vote_count', 'status',\n 'release_date', 'revenue', 'runtime', 'adult', 'backdrop_path',\n 'budget', 'homepage', 'imdb_id', 'original_language', 'original_title',\n 'overview', 'popularity', 'poster_path', 'tagline', 'genres',\n 'production_companies', 'production_countries', 'spoken_languages',\n 'keywords'],\n dtype='object')"},"metadata":{}}]},{"cell_type":"code","source":"df = df.drop( ['id' , 'vote_count' , 'status' , 'release_date', 'revenue' , 'backdrop_path',\n 'budget','homepage','imdb_id','original_title' , 'overview','poster_path',\n 'tagline' , 'production_companies','production_countries' ,'spoken_languages' ,'keywords'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.455428Z","iopub.execute_input":"2024-09-12T13:59:43.455860Z","iopub.status.idle":"2024-09-12T13:59:43.514130Z","shell.execute_reply.started":"2024-09-12T13:59:43.455797Z","shell.execute_reply":"2024-09-12T13:59:43.513049Z"},"trusted":True},"execution_count":8,"outputs":[]},{"cell_type":"code","source":"df['org_title']=df['title']","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.515749Z","iopub.execute_input":"2024-09-12T13:59:43.516161Z","iopub.status.idle":"2024-09-12T13:59:43.526800Z","shell.execute_reply.started":"2024-09-12T13:59:43.516098Z","shell.execute_reply":"2024-09-12T13:59:43.525164Z"},"trusted":True},"execution_count":9,"outputs":[]},{"cell_type":"code","source":"df.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.531013Z","iopub.execute_input":"2024-09-12T13:59:43.531509Z","iopub.status.idle":"2024-09-12T13:59:43.616119Z","shell.execute_reply.started":"2024-09-12T13:59:43.531459Z","shell.execute_reply":"2024-09-12T13:59:43.614893Z"},"trusted":True},"execution_count":10,"outputs":[{"execution_count":10,"output_type":"execute_result","data":{"text/plain":"index 0\ntitle 0\nvote_average 0\nruntime 0\nadult 0\noriginal_language 0\npopularity 0\ngenres 58964\norg_title 0\ndtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"df['genres'] = df['genres'].fillna('unknown')","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.617572Z","iopub.execute_input":"2024-09-12T13:59:43.618503Z","iopub.status.idle":"2024-09-12T13:59:43.655645Z","shell.execute_reply.started":"2024-09-12T13:59:43.618448Z","shell.execute_reply":"2024-09-12T13:59:43.654221Z"},"trusted":True},"execution_count":11,"outputs":[]},{"cell_type":"code","source":"df.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.657433Z","iopub.execute_input":"2024-09-12T13:59:43.657823Z","iopub.status.idle":"2024-09-12T13:59:43.737939Z","shell.execute_reply.started":"2024-09-12T13:59:43.657784Z","shell.execute_reply":"2024-09-12T13:59:43.736867Z"},"trusted":True},"execution_count":12,"outputs":[{"execution_count":12,"output_type":"execute_result","data":{"text/plain":"index 0\ntitle 0\nvote_average 0\nruntime 0\nadult 0\noriginal_language 0\npopularity 0\ngenres 0\norg_title 0\ndtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"df.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:43.739671Z","iopub.execute_input":"2024-09-12T13:59:43.740036Z","iopub.status.idle":"2024-09-12T13:59:44.069972Z","shell.execute_reply.started":"2024-09-12T13:59:43.739998Z","shell.execute_reply":"2024-09-12T13:59:44.068676Z"},"trusted":True},"execution_count":13,"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"0"},"metadata":{}}]},{"cell_type":"code","source":"df = df.drop_duplicates()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:44.071350Z","iopub.execute_input":"2024-09-12T13:59:44.071959Z","iopub.status.idle":"2024-09-12T13:59:44.440769Z","shell.execute_reply.started":"2024-09-12T13:59:44.071738Z","shell.execute_reply":"2024-09-12T13:59:44.439682Z"},"trusted":True},"execution_count":14,"outputs":[]},{"cell_type":"code","source":"df.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:44.442433Z","iopub.execute_input":"2024-09-12T13:59:44.442910Z","iopub.status.idle":"2024-09-12T13:59:44.760085Z","shell.execute_reply.started":"2024-09-12T13:59:44.442868Z","shell.execute_reply":"2024-09-12T13:59:44.758695Z"},"trusted":True},"execution_count":15,"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"0"},"metadata":{}}]},{"cell_type":"code","source":"dff= df.copy()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:44.761498Z","iopub.execute_input":"2024-09-12T13:59:44.761964Z","iopub.status.idle":"2024-09-12T13:59:44.781993Z","shell.execute_reply.started":"2024-09-12T13:59:44.761916Z","shell.execute_reply":"2024-09-12T13:59:44.780368Z"},"trusted":True},"execution_count":16,"outputs":[]},{"cell_type":"markdown","source":"# MultiLabel Encoder","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import OneHotEncoder, MultiLabelBinarizer\n\ngenre_l = dff['genres'].apply(lambda x: x.split(','))\ngenre_l = pd.DataFrame(genre_l)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:44.783600Z","iopub.execute_input":"2024-09-12T13:59:44.783977Z","iopub.status.idle":"2024-09-12T13:59:45.404819Z","shell.execute_reply.started":"2024-09-12T13:59:44.783938Z","shell.execute_reply":"2024-09-12T13:59:45.403404Z"},"trusted":True},"execution_count":17,"outputs":[]},{"cell_type":"code","source":"genre_l","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:45.406505Z","iopub.execute_input":"2024-09-12T13:59:45.407007Z","iopub.status.idle":"2024-09-12T13:59:45.426034Z","shell.execute_reply.started":"2024-09-12T13:59:45.406952Z","shell.execute_reply":"2024-09-12T13:59:45.424721Z"},"trusted":True},"execution_count":18,"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":" genres\n0 [Action, Science Fiction, Adventure]\n1 [Adventure, Drama, Science Fiction]\n2 [Drama, Action, Crime, Thriller]\n3 [Action, Adventure, Fantasy, Science Fiction]\n4 [Science Fiction, Action, Adventure]\n... ...\n349033 [Animation, Comedy]\n349034 [unknown]\n349035 [Documentary]\n349036 [unknown]\n349037 [Science Fiction]\n\n[349038 rows x 1 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>genres</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>[Action, Science Fiction, Adventure]</td>\n </tr>\n <tr>\n <th>1</th>\n <td>[Adventure, Drama, Science Fiction]</td>\n </tr>\n <tr>\n <th>2</th>\n <td>[Drama, Action, Crime, Thriller]</td>\n </tr>\n <tr>\n <th>3</th>\n <td>[Action, Adventure, Fantasy, Science Fiction]</td>\n </tr>\n <tr>\n <th>4</th>\n <td>[Science Fiction, Action, Adventure]</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n </tr>\n <tr>\n <th>349033</th>\n <td>[Animation, Comedy]</td>\n </tr>\n <tr>\n <th>349034</th>\n <td>[unknown]</td>\n </tr>\n <tr>\n <th>349035</th>\n <td>[Documentary]</td>\n </tr>\n <tr>\n <th>349036</th>\n <td>[unknown]</td>\n </tr>\n <tr>\n <th>349037</th>\n <td>[Science Fiction]</td>\n </tr>\n </tbody>\n</table>\n<p>349038 rows × 1 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"genre_l['genres'] = genre_l['genres'].apply(lambda x :[ y.strip().lower().replace(' ','') for y in x] )","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:45.427515Z","iopub.execute_input":"2024-09-12T13:59:45.427948Z","iopub.status.idle":"2024-09-12T13:59:46.163173Z","shell.execute_reply.started":"2024-09-12T13:59:45.427896Z","shell.execute_reply":"2024-09-12T13:59:46.161824Z"},"trusted":True},"execution_count":19,"outputs":[]},{"cell_type":"code","source":"MLB = MultiLabelBinarizer()\n\ngenre_encoded = MLB.fit_transform(genre_l['genres'])","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.164752Z","iopub.execute_input":"2024-09-12T13:59:46.165171Z","iopub.status.idle":"2024-09-12T13:59:46.538121Z","shell.execute_reply.started":"2024-09-12T13:59:46.165122Z","shell.execute_reply":"2024-09-12T13:59:46.536892Z"},"trusted":True},"execution_count":20,"outputs":[]},{"cell_type":"code","source":"genre_encoded","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.539572Z","iopub.execute_input":"2024-09-12T13:59:46.540079Z","iopub.status.idle":"2024-09-12T13:59:46.548567Z","shell.execute_reply.started":"2024-09-12T13:59:46.540031Z","shell.execute_reply":"2024-09-12T13:59:46.547281Z"},"trusted":True},"execution_count":21,"outputs":[{"execution_count":21,"output_type":"execute_result","data":{"text/plain":"array([[1, 1, 0, ..., 0, 0, 0],\n [0, 1, 0, ..., 0, 0, 0],\n [1, 0, 0, ..., 0, 0, 0],\n ...,\n [0, 0, 0, ..., 0, 0, 0],\n [0, 0, 0, ..., 1, 0, 0],\n [0, 0, 0, ..., 0, 0, 0]])"},"metadata":{}}]},{"cell_type":"code","source":"genre_encoded_df = pd.DataFrame(genre_encoded, columns=MLB.classes_)\ngenre_encoded_df=genre_encoded_df.reset_index()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.549844Z","iopub.execute_input":"2024-09-12T13:59:46.550237Z","iopub.status.idle":"2024-09-12T13:59:46.646971Z","shell.execute_reply.started":"2024-09-12T13:59:46.550176Z","shell.execute_reply":"2024-09-12T13:59:46.645467Z"},"trusted":True},"execution_count":22,"outputs":[]},{"cell_type":"code","source":"mod_df = dff.drop(['genres'],axis=1)\nmod_df=mod_df.reset_index()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.648686Z","iopub.execute_input":"2024-09-12T13:59:46.649197Z","iopub.status.idle":"2024-09-12T13:59:46.702685Z","shell.execute_reply.started":"2024-09-12T13:59:46.649140Z","shell.execute_reply":"2024-09-12T13:59:46.701539Z"},"trusted":True},"execution_count":23,"outputs":[]},{"cell_type":"code","source":"df = pd.concat([mod_df,genre_encoded_df],axis=1).drop('index',axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.704495Z","iopub.execute_input":"2024-09-12T13:59:46.704877Z","iopub.status.idle":"2024-09-12T13:59:46.848519Z","shell.execute_reply.started":"2024-09-12T13:59:46.704836Z","shell.execute_reply":"2024-09-12T13:59:46.847223Z"},"trusted":True},"execution_count":24,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.849827Z","iopub.execute_input":"2024-09-12T13:59:46.850218Z","iopub.status.idle":"2024-09-12T13:59:46.875836Z","shell.execute_reply.started":"2024-09-12T13:59:46.850178Z","shell.execute_reply":"2024-09-12T13:59:46.874371Z"},"trusted":True},"execution_count":25,"outputs":[{"execution_count":25,"output_type":"execute_result","data":{"text/plain":" level_0 title vote_average runtime adult original_language \\\n0 0 Inception 8.364 148 False en \n1 1 Interstellar 8.417 169 False en \n2 2 The Dark Knight 8.512 152 False en \n3 3 Avatar 7.573 162 False en \n4 4 The Avengers 7.710 143 False en \n\n popularity org_title action adventure ... horror music \\\n0 83.952 Inception 1 1 ... 0 0 \n1 140.241 Interstellar 0 1 ... 0 0 \n2 130.643 The Dark Knight 1 0 ... 0 0 \n3 79.932 Avatar 1 1 ... 0 0 \n4 98.082 The Avengers 1 1 ... 0 0 \n\n mystery romance sciencefiction thriller tvmovie unknown war western \n0 0 0 1 0 0 0 0 0 \n1 0 0 1 0 0 0 0 0 \n2 0 0 0 1 0 0 0 0 \n3 0 0 1 0 0 0 0 0 \n4 0 0 1 0 0 0 0 0 \n\n[5 rows x 28 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>level_0</th>\n <th>title</th>\n <th>vote_average</th>\n <th>runtime</th>\n <th>adult</th>\n <th>original_language</th>\n <th>popularity</th>\n <th>org_title</th>\n <th>action</th>\n <th>adventure</th>\n <th>...</th>\n <th>horror</th>\n <th>music</th>\n <th>mystery</th>\n <th>romance</th>\n <th>sciencefiction</th>\n <th>thriller</th>\n <th>tvmovie</th>\n <th>unknown</th>\n <th>war</th>\n <th>western</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0</td>\n <td>Inception</td>\n <td>8.364</td>\n <td>148</td>\n <td>False</td>\n <td>en</td>\n <td>83.952</td>\n <td>Inception</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1</td>\n <td>Interstellar</td>\n <td>8.417</td>\n <td>169</td>\n <td>False</td>\n <td>en</td>\n <td>140.241</td>\n <td>Interstellar</td>\n <td>0</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2</td>\n <td>The Dark Knight</td>\n <td>8.512</td>\n <td>152</td>\n <td>False</td>\n <td>en</td>\n <td>130.643</td>\n <td>The Dark Knight</td>\n <td>1</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3</td>\n <td>Avatar</td>\n <td>7.573</td>\n <td>162</td>\n <td>False</td>\n <td>en</td>\n <td>79.932</td>\n <td>Avatar</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4</td>\n <td>The Avengers</td>\n <td>7.710</td>\n <td>143</td>\n <td>False</td>\n <td>en</td>\n <td>98.082</td>\n <td>The Avengers</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 28 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"# Features Engineering","metadata":{}},{"cell_type":"code","source":"df['title'] = df['title'].apply(lambda x :x.strip().lower().replace(' ','') )\ndf['original_language'] = df['original_language'].apply(lambda x :x.strip().lower().replace(' ','') )","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:46.877527Z","iopub.execute_input":"2024-09-12T13:59:46.878059Z","iopub.status.idle":"2024-09-12T13:59:47.232711Z","shell.execute_reply.started":"2024-09-12T13:59:46.877984Z","shell.execute_reply":"2024-09-12T13:59:47.231579Z"},"trusted":True},"execution_count":26,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.234096Z","iopub.execute_input":"2024-09-12T13:59:47.234477Z","iopub.status.idle":"2024-09-12T13:59:47.258985Z","shell.execute_reply.started":"2024-09-12T13:59:47.234441Z","shell.execute_reply":"2024-09-12T13:59:47.257562Z"},"trusted":True},"execution_count":27,"outputs":[{"execution_count":27,"output_type":"execute_result","data":{"text/plain":" level_0 title vote_average runtime adult original_language \\\n0 0 inception 8.364 148 False en \n1 1 interstellar 8.417 169 False en \n2 2 thedarkknight 8.512 152 False en \n3 3 avatar 7.573 162 False en \n4 4 theavengers 7.710 143 False en \n\n popularity org_title action adventure ... horror music \\\n0 83.952 Inception 1 1 ... 0 0 \n1 140.241 Interstellar 0 1 ... 0 0 \n2 130.643 The Dark Knight 1 0 ... 0 0 \n3 79.932 Avatar 1 1 ... 0 0 \n4 98.082 The Avengers 1 1 ... 0 0 \n\n mystery romance sciencefiction thriller tvmovie unknown war western \n0 0 0 1 0 0 0 0 0 \n1 0 0 1 0 0 0 0 0 \n2 0 0 0 1 0 0 0 0 \n3 0 0 1 0 0 0 0 0 \n4 0 0 1 0 0 0 0 0 \n\n[5 rows x 28 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>level_0</th>\n <th>title</th>\n <th>vote_average</th>\n <th>runtime</th>\n <th>adult</th>\n <th>original_language</th>\n <th>popularity</th>\n <th>org_title</th>\n <th>action</th>\n <th>adventure</th>\n <th>...</th>\n <th>horror</th>\n <th>music</th>\n <th>mystery</th>\n <th>romance</th>\n <th>sciencefiction</th>\n <th>thriller</th>\n <th>tvmovie</th>\n <th>unknown</th>\n <th>war</th>\n <th>western</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0</td>\n <td>inception</td>\n <td>8.364</td>\n <td>148</td>\n <td>False</td>\n <td>en</td>\n <td>83.952</td>\n <td>Inception</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1</td>\n <td>interstellar</td>\n <td>8.417</td>\n <td>169</td>\n <td>False</td>\n <td>en</td>\n <td>140.241</td>\n <td>Interstellar</td>\n <td>0</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2</td>\n <td>thedarkknight</td>\n <td>8.512</td>\n <td>152</td>\n <td>False</td>\n <td>en</td>\n <td>130.643</td>\n <td>The Dark Knight</td>\n <td>1</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3</td>\n <td>avatar</td>\n <td>7.573</td>\n <td>162</td>\n <td>False</td>\n <td>en</td>\n <td>79.932</td>\n <td>Avatar</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4</td>\n <td>theavengers</td>\n <td>7.710</td>\n <td>143</td>\n <td>False</td>\n <td>en</td>\n <td>98.082</td>\n <td>The Avengers</td>\n <td>1</td>\n <td>1</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 28 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"df.loc[~( (df['original_language']=='en')|(df['original_language']=='fr')|(df['original_language']=='es')|(df['original_language']=='de')|(df['original_language']=='ja')),'original_language'] = 'else'","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.265294Z","iopub.execute_input":"2024-09-12T13:59:47.266759Z","iopub.status.idle":"2024-09-12T13:59:47.427983Z","shell.execute_reply.started":"2024-09-12T13:59:47.266710Z","shell.execute_reply":"2024-09-12T13:59:47.426344Z"},"trusted":True},"execution_count":28,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":None,"outputs":[]},{"cell_type":"markdown","source":"# One-Hot Encoding","metadata":{}},{"cell_type":"code","source":"OHE = OneHotEncoder(sparse_output=False)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.429338Z","iopub.execute_input":"2024-09-12T13:59:47.429692Z","iopub.status.idle":"2024-09-12T13:59:47.434762Z","shell.execute_reply.started":"2024-09-12T13:59:47.429655Z","shell.execute_reply":"2024-09-12T13:59:47.433548Z"},"trusted":True},"execution_count":29,"outputs":[]},{"cell_type":"code","source":"df['adult'] = df['adult'].astype('str')\nadult_enc = OHE.fit_transform(df[['adult']])\nadult_enc_df = pd.DataFrame(adult_enc,columns=OHE.get_feature_names_out())","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.436328Z","iopub.execute_input":"2024-09-12T13:59:47.436732Z","iopub.status.idle":"2024-09-12T13:59:47.639201Z","shell.execute_reply.started":"2024-09-12T13:59:47.436683Z","shell.execute_reply":"2024-09-12T13:59:47.637731Z"},"trusted":True},"execution_count":30,"outputs":[]},{"cell_type":"code","source":"adult_enc_df = adult_enc_df.drop('adult_True',axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.640902Z","iopub.execute_input":"2024-09-12T13:59:47.641449Z","iopub.status.idle":"2024-09-12T13:59:47.648095Z","shell.execute_reply.started":"2024-09-12T13:59:47.641406Z","shell.execute_reply":"2024-09-12T13:59:47.646817Z"},"trusted":True},"execution_count":31,"outputs":[]},{"cell_type":"code","source":"lang_enc = OHE.fit_transform(df[['original_language']])\nlang_enc_df = pd.DataFrame(lang_enc,columns=OHE.get_feature_names_out())","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.649553Z","iopub.execute_input":"2024-09-12T13:59:47.650056Z","iopub.status.idle":"2024-09-12T13:59:47.790485Z","shell.execute_reply.started":"2024-09-12T13:59:47.649994Z","shell.execute_reply":"2024-09-12T13:59:47.789208Z"},"trusted":True},"execution_count":32,"outputs":[]},{"cell_type":"code","source":"mod_df = df.drop(['adult','original_language'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.791701Z","iopub.execute_input":"2024-09-12T13:59:47.792073Z","iopub.status.idle":"2024-09-12T13:59:47.840566Z","shell.execute_reply.started":"2024-09-12T13:59:47.792027Z","shell.execute_reply":"2024-09-12T13:59:47.839277Z"},"trusted":True},"execution_count":33,"outputs":[]},{"cell_type":"code","source":"df = pd.concat([mod_df,adult_enc_df,lang_enc_df],axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.841842Z","iopub.execute_input":"2024-09-12T13:59:47.842219Z","iopub.status.idle":"2024-09-12T13:59:47.975276Z","shell.execute_reply.started":"2024-09-12T13:59:47.842183Z","shell.execute_reply":"2024-09-12T13:59:47.974044Z"},"trusted":True},"execution_count":34,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:47.976621Z","iopub.execute_input":"2024-09-12T13:59:47.976990Z","iopub.status.idle":"2024-09-12T13:59:48.005050Z","shell.execute_reply.started":"2024-09-12T13:59:47.976953Z","shell.execute_reply":"2024-09-12T13:59:48.003895Z"},"trusted":True},"execution_count":35,"outputs":[{"execution_count":35,"output_type":"execute_result","data":{"text/plain":" level_0 title vote_average runtime popularity org_title \\\n0 0 inception 8.364 148 83.952 Inception \n1 1 interstellar 8.417 169 140.241 Interstellar \n2 2 thedarkknight 8.512 152 130.643 The Dark Knight \n3 3 avatar 7.573 162 79.932 Avatar \n4 4 theavengers 7.710 143 98.082 The Avengers \n\n action adventure animation comedy ... unknown war western \\\n0 1 1 0 0 ... 0 0 0 \n1 0 1 0 0 ... 0 0 0 \n2 1 0 0 0 ... 0 0 0 \n3 1 1 0 0 ... 0 0 0 \n4 1 1 0 0 ... 0 0 0 \n\n adult_False original_language_de original_language_else \\\n0 1.0 0.0 0.0 \n1 1.0 0.0 0.0 \n2 1.0 0.0 0.0 \n3 1.0 0.0 0.0 \n4 1.0 0.0 0.0 \n\n original_language_en original_language_es original_language_fr \\\n0 1.0 0.0 0.0 \n1 1.0 0.0 0.0 \n2 1.0 0.0 0.0 \n3 1.0 0.0 0.0 \n4 1.0 0.0 0.0 \n\n original_language_ja \n0 0.0 \n1 0.0 \n2 0.0 \n3 0.0 \n4 0.0 \n\n[5 rows x 33 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>level_0</th>\n <th>title</th>\n <th>vote_average</th>\n <th>runtime</th>\n <th>popularity</th>\n <th>org_title</th>\n <th>action</th>\n <th>adventure</th>\n <th>animation</th>\n <th>comedy</th>\n <th>...</th>\n <th>unknown</th>\n <th>war</th>\n <th>western</th>\n <th>adult_False</th>\n <th>original_language_de</th>\n <th>original_language_else</th>\n <th>original_language_en</th>\n <th>original_language_es</th>\n <th>original_language_fr</th>\n <th>original_language_ja</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0</td>\n <td>inception</td>\n <td>8.364</td>\n <td>148</td>\n <td>83.952</td>\n <td>Inception</td>\n <td>1</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1</td>\n <td>interstellar</td>\n <td>8.417</td>\n <td>169</td>\n <td>140.241</td>\n <td>Interstellar</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2</td>\n <td>thedarkknight</td>\n <td>8.512</td>\n <td>152</td>\n <td>130.643</td>\n <td>The Dark Knight</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3</td>\n <td>avatar</td>\n <td>7.573</td>\n <td>162</td>\n <td>79.932</td>\n <td>Avatar</td>\n <td>1</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4</td>\n <td>theavengers</td>\n <td>7.710</td>\n <td>143</td>\n <td>98.082</td>\n <td>The Avengers</td>\n <td>1</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>...</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.0</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 33 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"","metadata":{},"execution_count":None,"outputs":[]},{"cell_type":"markdown","source":"# Normalization","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\nSC = StandardScaler()\ndf_norm = SC.fit_transform(df.drop(['title','org_title'],axis=1))\ndf_norm_df = pd.DataFrame(df_norm, columns=[x for x in df.columns if x not in ['title', 'org_title']])\ndf = pd.concat([df[['title','org_title']],df_norm_df],axis=1)\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:48.006949Z","iopub.execute_input":"2024-09-12T13:59:48.007456Z","iopub.status.idle":"2024-09-12T13:59:48.354397Z","shell.execute_reply.started":"2024-09-12T13:59:48.007403Z","shell.execute_reply":"2024-09-12T13:59:48.353015Z"},"trusted":True},"execution_count":36,"outputs":[{"execution_count":36,"output_type":"execute_result","data":{"text/plain":" title org_title level_0 vote_average runtime \\\n0 inception Inception -1.732046 1.156745 1.193328 \n1 interstellar Interstellar -1.732036 1.183750 1.516277 \n2 thedarkknight The Dark Knight -1.732026 1.232154 1.254842 \n3 avatar Avatar -1.732016 0.753715 1.408628 \n4 theavengers The Avengers -1.732006 0.823519 1.116435 \n\n popularity action adventure animation comedy ... unknown \\\n0 6.055067 3.468377 4.804326 -0.254952 -0.524863 ... -0.450857 \n1 10.245121 -0.288319 4.804326 -0.254952 -0.524863 ... -0.450857 \n2 9.530663 3.468377 -0.208146 -0.254952 -0.524863 ... -0.450857 \n3 5.755825 3.468377 4.804326 -0.254952 -0.524863 ... -0.450857 \n4 7.106879 3.468377 4.804326 -0.254952 -0.524863 ... -0.450857 \n\n war western adult_False original_language_de \\\n0 -0.132835 -0.114207 0.243481 -0.21469 \n1 -0.132835 -0.114207 0.243481 -0.21469 \n2 -0.132835 -0.114207 0.243481 -0.21469 \n3 -0.132835 -0.114207 0.243481 -0.21469 \n4 -0.132835 -0.114207 0.243481 -0.21469 \n\n original_language_else original_language_en original_language_es \\\n0 -0.58974 0.962307 -0.273054 \n1 -0.58974 0.962307 -0.273054 \n2 -0.58974 0.962307 -0.273054 \n3 -0.58974 0.962307 -0.273054 \n4 -0.58974 0.962307 -0.273054 \n\n original_language_fr original_language_ja \n0 -0.274818 -0.201679 \n1 -0.274818 -0.201679 \n2 -0.274818 -0.201679 \n3 -0.274818 -0.201679 \n4 -0.274818 -0.201679 \n\n[5 rows x 33 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>title</th>\n <th>org_title</th>\n <th>level_0</th>\n <th>vote_average</th>\n <th>runtime</th>\n <th>popularity</th>\n <th>action</th>\n <th>adventure</th>\n <th>animation</th>\n <th>comedy</th>\n <th>...</th>\n <th>unknown</th>\n <th>war</th>\n <th>western</th>\n <th>adult_False</th>\n <th>original_language_de</th>\n <th>original_language_else</th>\n <th>original_language_en</th>\n <th>original_language_es</th>\n <th>original_language_fr</th>\n <th>original_language_ja</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>inception</td>\n <td>Inception</td>\n <td>-1.732046</td>\n <td>1.156745</td>\n <td>1.193328</td>\n <td>6.055067</td>\n <td>3.468377</td>\n <td>4.804326</td>\n <td>-0.254952</td>\n <td>-0.524863</td>\n <td>...</td>\n <td>-0.450857</td>\n <td>-0.132835</td>\n <td>-0.114207</td>\n <td>0.243481</td>\n <td>-0.21469</td>\n <td>-0.58974</td>\n <td>0.962307</td>\n <td>-0.273054</td>\n <td>-0.274818</td>\n <td>-0.201679</td>\n </tr>\n <tr>\n <th>1</th>\n <td>interstellar</td>\n <td>Interstellar</td>\n <td>-1.732036</td>\n <td>1.183750</td>\n <td>1.516277</td>\n <td>10.245121</td>\n <td>-0.288319</td>\n <td>4.804326</td>\n <td>-0.254952</td>\n <td>-0.524863</td>\n <td>...</td>\n <td>-0.450857</td>\n <td>-0.132835</td>\n <td>-0.114207</td>\n <td>0.243481</td>\n <td>-0.21469</td>\n <td>-0.58974</td>\n <td>0.962307</td>\n <td>-0.273054</td>\n <td>-0.274818</td>\n <td>-0.201679</td>\n </tr>\n <tr>\n <th>2</th>\n <td>thedarkknight</td>\n <td>The Dark Knight</td>\n <td>-1.732026</td>\n <td>1.232154</td>\n <td>1.254842</td>\n <td>9.530663</td>\n <td>3.468377</td>\n <td>-0.208146</td>\n <td>-0.254952</td>\n <td>-0.524863</td>\n <td>...</td>\n <td>-0.450857</td>\n <td>-0.132835</td>\n <td>-0.114207</td>\n <td>0.243481</td>\n <td>-0.21469</td>\n <td>-0.58974</td>\n <td>0.962307</td>\n <td>-0.273054</td>\n <td>-0.274818</td>\n <td>-0.201679</td>\n </tr>\n <tr>\n <th>3</th>\n <td>avatar</td>\n <td>Avatar</td>\n <td>-1.732016</td>\n <td>0.753715</td>\n <td>1.408628</td>\n <td>5.755825</td>\n <td>3.468377</td>\n <td>4.804326</td>\n <td>-0.254952</td>\n <td>-0.524863</td>\n <td>...</td>\n <td>-0.450857</td>\n <td>-0.132835</td>\n <td>-0.114207</td>\n <td>0.243481</td>\n <td>-0.21469</td>\n <td>-0.58974</td>\n <td>0.962307</td>\n <td>-0.273054</td>\n <td>-0.274818</td>\n <td>-0.201679</td>\n </tr>\n <tr>\n <th>4</th>\n <td>theavengers</td>\n <td>The Avengers</td>\n <td>-1.732006</td>\n <td>0.823519</td>\n <td>1.116435</td>\n <td>7.106879</td>\n <td>3.468377</td>\n <td>4.804326</td>\n <td>-0.254952</td>\n <td>-0.524863</td>\n <td>...</td>\n <td>-0.450857</td>\n <td>-0.132835</td>\n <td>-0.114207</td>\n <td>0.243481</td>\n <td>-0.21469</td>\n <td>-0.58974</td>\n <td>0.962307</td>\n <td>-0.273054</td>\n <td>-0.274818</td>\n <td>-0.201679</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 33 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"","metadata":{},"execution_count":None,"outputs":[]},{"cell_type":"markdown","source":"# Handling Duplicates","metadata":{}},{"cell_type":"code","source":"df = df.drop_duplicates(subset=['title'])\ndf=df.set_index(['title'])\ndf_fin=df.drop('org_title',axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:48.355835Z","iopub.execute_input":"2024-09-12T13:59:48.356241Z","iopub.status.idle":"2024-09-12T13:59:48.564990Z","shell.execute_reply.started":"2024-09-12T13:59:48.356202Z","shell.execute_reply":"2024-09-12T13:59:48.563868Z"},"trusted":True},"execution_count":37,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":None,"outputs":[]},{"cell_type":"markdown","source":"# Cosine-Similatry","metadata":{}},{"cell_type":"code","source":"movie_name = 'the dark knight'\nmovie_name=movie_name.strip().lower().replace(' ','')\nnew_df= df_fin.loc[[movie_name]]\nnew_df = new_df.values.reshape(1,-1)\nfrom sklearn.metrics.pairwise import cosine_similarity\ndf_other = df_fin.loc[df_fin.index!=movie_name,:]\ndf_titles = df.loc[df.index!=movie_name,'org_title']\ncosine_sim_matrix = cosine_similarity(new_df,df_other)\ncosine_sim_df = pd.DataFrame(cosine_sim_matrix,index=[movie_name],columns=df_titles)\n\ncosine_sim_df","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:48.566386Z","iopub.execute_input":"2024-09-12T13:59:48.566739Z","iopub.status.idle":"2024-09-12T13:59:49.206075Z","shell.execute_reply.started":"2024-09-12T13:59:48.566705Z","shell.execute_reply":"2024-09-12T13:59:49.204939Z"},"trusted":True},"execution_count":38,"outputs":[{"execution_count":38,"output_type":"execute_result","data":{"text/plain":"org_title Inception Interstellar Avatar The Avengers Deadpool \\\nthedarkknight 0.591092 0.674085 0.503908 0.631122 0.628958 \n\norg_title Avengers: Infinity War Fight Club Guardians of the Galaxy \\\nthedarkknight 0.733181 0.778691 0.352667 \n\norg_title Pulp Fiction Forrest Gump ... La solapa \\\nthedarkknight 0.887382 0.7002 ... -0.139698 \n\norg_title Lonely Laura and Her Sister Niamh \\\nthedarkknight -0.08233 \n\norg_title Idol × Warrior: Miracle Tunes! Pilot \\\nthedarkknight -0.095234 \n\norg_title Oceans Apart: Greed, Betrayal and Pacific Island Rugby \\\nthedarkknight -0.128858 \n\norg_title Dangerously Delicious: Paid Advertisement One Foot Crane \\\nthedarkknight -0.157923 0.087291 \n\norg_title Triomf Tom Goes to the Mayor Returns DHONG \\\nthedarkknight -0.14619 -0.155169 -0.171874 \n\norg_title More Dirty Debutantes 35 \nthedarkknight -0.073789 \n\n[1 rows x 306945 columns]","text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th>org_title</th>\n <th>Inception</th>\n <th>Interstellar</th>\n <th>Avatar</th>\n <th>The Avengers</th>\n <th>Deadpool</th>\n <th>Avengers: Infinity War</th>\n <th>Fight Club</th>\n <th>Guardians of the Galaxy</th>\n <th>Pulp Fiction</th>\n <th>Forrest Gump</th>\n <th>...</th>\n <th>La solapa</th>\n <th>Lonely Laura and Her Sister Niamh</th>\n <th>Idol × Warrior: Miracle Tunes! Pilot</th>\n <th>Oceans Apart: Greed, Betrayal and Pacific Island Rugby</th>\n <th>Dangerously Delicious: Paid Advertisement</th>\n <th>One Foot Crane</th>\n <th>Triomf</th>\n <th>Tom Goes to the Mayor Returns</th>\n <th>DHONG</th>\n <th>More Dirty Debutantes 35</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>thedarkknight</th>\n <td>0.591092</td>\n <td>0.674085</td>\n <td>0.503908</td>\n <td>0.631122</td>\n <td>0.628958</td>\n <td>0.733181</td>\n <td>0.778691</td>\n <td>0.352667</td>\n <td>0.887382</td>\n <td>0.7002</td>\n <td>...</td>\n <td>-0.139698</td>\n <td>-0.08233</td>\n <td>-0.095234</td>\n <td>-0.128858</td>\n <td>-0.157923</td>\n <td>0.087291</td>\n <td>-0.14619</td>\n <td>-0.155169</td>\n <td>-0.171874</td>\n <td>-0.073789</td>\n </tr>\n </tbody>\n</table>\n<p>1 rows × 306945 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"sorted_row = cosine_sim_df.loc[movie_name].sort_values(ascending=False)[0:20]","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:49.207931Z","iopub.execute_input":"2024-09-12T13:59:49.208439Z","iopub.status.idle":"2024-09-12T13:59:49.283699Z","shell.execute_reply.started":"2024-09-12T13:59:49.208391Z","shell.execute_reply":"2024-09-12T13:59:49.282418Z"},"trusted":True},"execution_count":39,"outputs":[]},{"cell_type":"code","source":"sorted_row.index[5]","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:49.285342Z","iopub.execute_input":"2024-09-12T13:59:49.286300Z","iopub.status.idle":"2024-09-12T13:59:49.293455Z","shell.execute_reply.started":"2024-09-12T13:59:49.286245Z","shell.execute_reply":"2024-09-12T13:59:49.292194Z"},"trusted":True},"execution_count":40,"outputs":[{"execution_count":40,"output_type":"execute_result","data":{"text/plain":"'The Equalizer 2'"},"metadata":{}}]},{"cell_type":"code","source":"pip install --force-reinstall google-cloud-storage==2.2.1 urllib3<2.0.0 scipy<1.14\n","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:49.295061Z","iopub.execute_input":"2024-09-12T13:59:49.295564Z","iopub.status.idle":"2024-09-12T13:59:50.418653Z","shell.execute_reply.started":"2024-09-12T13:59:49.295512Z","shell.execute_reply":"2024-09-12T13:59:50.416996Z"},"trusted":True},"execution_count":41,"outputs":[{"name":"stdout","text":"/bin/bash: 2.0.0: No such file or directory\nNote: you may need to restart the kernel to use updated packages.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"# Deployment","metadata":{}},{"cell_type":"code","source":"pip install scipy<1.14\n","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:50.420634Z","iopub.execute_input":"2024-09-12T13:59:50.421142Z","iopub.status.idle":"2024-09-12T13:59:51.531868Z","shell.execute_reply.started":"2024-09-12T13:59:50.421082Z","shell.execute_reply":"2024-09-12T13:59:51.530424Z"},"trusted":True},"execution_count":42,"outputs":[{"name":"stdout","text":"/bin/bash: 1.14: No such file or directory\nNote: you may need to restart the kernel to use updated packages.\n","output_type":"stream"}]},{"cell_type":"code","source":"pip install google-cloud-storage==2.2.1\n","metadata":{"execution":{"iopub.status.busy":"2024-09-12T13:59:51.533728Z","iopub.execute_input":"2024-09-12T13:59:51.534155Z","iopub.status.idle":"2024-09-12T14:00:24.203253Z","shell.execute_reply.started":"2024-09-12T13:59:51.534094Z","shell.execute_reply":"2024-09-12T14:00:24.201426Z"},"trusted":True},"execution_count":43,"outputs":[{"name":"stdout","text":"Collecting google-cloud-storage==2.2.1\n Downloading google_cloud_storage-2.2.1-py2.py3-None-any.whl.metadata (5.3 kB)\nRequirement already satisfied: google-auth<3.0dev,>=1.25.0 in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (2.30.0)\nRequirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5 in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (2.11.1)\nRequirement already satisfied: google-cloud-core<3.0dev,>=1.6.0 in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (2.4.1)\nRequirement already satisfied: google-resumable-media>=2.3.2 in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (2.7.1)\nRequirement already satisfied: requests<3.0.0dev,>=2.18.0 in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (2.32.3)\nRequirement already satisfied: protobuf in /opt/conda/lib/python3.10/site-packages (from google-cloud-storage==2.2.1) (3.20.3)\nRequirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in /opt/conda/lib/python3.10/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-storage==2.2.1) (1.63.1)\nRequirement already satisfied: cachetools<6.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from google-auth<3.0dev,>=1.25.0->google-cloud-storage==2.2.1) (4.2.4)\nRequirement already satisfied: pyasn1-modules>=0.2.1 in /opt/conda/lib/python3.10/site-packages (from google-auth<3.0dev,>=1.25.0->google-cloud-storage==2.2.1) (0.4.0)\nRequirement already satisfied: rsa<5,>=3.1.4 in /opt/conda/lib/python3.10/site-packages (from google-auth<3.0dev,>=1.25.0->google-cloud-storage==2.2.1) (4.9)\nRequirement already satisfied: google-crc32c<2.0dev,>=1.0 in /opt/conda/lib/python3.10/site-packages (from google-resumable-media>=2.3.2->google-cloud-storage==2.2.1) (1.5.0)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0dev,>=2.18.0->google-cloud-storage==2.2.1) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0dev,>=2.18.0->google-cloud-storage==2.2.1) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0dev,>=2.18.0->google-cloud-storage==2.2.1) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0dev,>=2.18.0->google-cloud-storage==2.2.1) (2024.7.4)\nRequirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /opt/conda/lib/python3.10/site-packages (from pyasn1-modules>=0.2.1->google-auth<3.0dev,>=1.25.0->google-cloud-storage==2.2.1) (0.6.0)\nDownloading google_cloud_storage-2.2.1-py2.py3-None-any.whl (107 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.1/107.1 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n\u001b[?25hInstalling collected packages: google-cloud-storage\n Attempting uninstall: google-cloud-storage\n Found existing installation: google-cloud-storage 1.44.0\n Uninstalling google-cloud-storage-1.44.0:\n Successfully uninstalled google-cloud-storage-1.44.0\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\nbeatrix-jupyterlab 2024.66.154055 requires jupyterlab~=3.6.0, but you have jupyterlab 4.2.4 which is incompatible.\nbigframes 0.22.0 requires google-cloud-bigquery[bqstorage,pandas]>=3.10.0, but you have google-cloud-bigquery 2.34.4 which is incompatible.\nbigframes 0.22.0 requires pandas<2.1.4,>=1.5.0, but you have pandas 2.2.2 which is incompatible.\ndataproc-jupyter-plugin 0.1.79 requires pydantic~=1.10.0, but you have pydantic 2.8.2 which is incompatible.\ngoogle-cloud-aiplatform 0.6.0a1 requires google-api-core[grpc]<2.0.0dev,>=1.22.2, but you have google-api-core 2.11.1 which is incompatible.\ngoogle-cloud-aiplatform 0.6.0a1 requires google-cloud-storage<2.0.0dev,>=1.26.0, but you have google-cloud-storage 2.2.1 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed google-cloud-storage-2.2.1\nNote: you may need to restart the kernel to use updated packages.\n","output_type":"stream"}]},{"cell_type":"code","source":"pip install urllib3<2.0.0\n","metadata":{"execution":{"iopub.status.busy":"2024-09-12T14:00:24.205680Z","iopub.execute_input":"2024-09-12T14:00:24.206352Z","iopub.status.idle":"2024-09-12T14:00:25.352457Z","shell.execute_reply.started":"2024-09-12T14:00:24.206292Z","shell.execute_reply":"2024-09-12T14:00:25.350999Z"},"trusted":True},"execution_count":44,"outputs":[{"name":"stdout","text":"/bin/bash: 2.0.0: No such file or directory\nNote: you may need to restart the kernel to use updated packages.\n","output_type":"stream"}]},{"cell_type":"code","source":"!pip install gradio\nimport gradio as gr\nfrom sklearn.metrics.pairwise import cosine_similarity\ndef predict(movie_name,no_movies):\n movie_name=movie_name.strip().lower().replace(' ','')\n if(movie_name in df_fin.index):\n new_df= df_fin.loc[[movie_name]]\n new_df = new_df.values.reshape(1,-1)\n df_other = df_fin.loc[df_fin.index!=movie_name,:]\n df_titles = df.loc[df.index!=movie_name,'org_title']\n cosine_sim_matrix = cosine_similarity(new_df,df_other)\n cosine_sim_df = pd.DataFrame(cosine_sim_matrix,index=[movie_name],columns=df_titles)\n sorted_row = cosine_sim_df.loc[movie_name].sort_values(ascending=False)[0:int(no_movies)]\n rec=''\n for i in range(int(no_movies)):\n rec+=(sorted_row.index[i])+'\\n'\n return rec\n else:\n return \"Sorry, this movie isn't in our database. \\n try another one !\"\n\n# Define the Gradio interface\ninterface = gr.Interface(\n fn=predict, # The function to be called\n inputs=[gr.Textbox(label=\"Movie Name : \"),\n gr.Textbox(label='No.of Recommendations: ',value= '5')],# Input type\n outputs=gr.Textbox(label=\"Recommendations : \") # Output type\n)\ninterface.launch()","metadata":{"execution":{"iopub.status.busy":"2024-09-12T14:00:25.354254Z","iopub.execute_input":"2024-09-12T14:00:25.354672Z","iopub.status.idle":"2024-09-12T14:00:52.234159Z","shell.execute_reply.started":"2024-09-12T14:00:25.354624Z","shell.execute_reply":"2024-09-12T14:00:52.232597Z"},"trusted":True},"execution_count":45,"outputs":[{"name":"stdout","text":"Collecting gradio\n Downloading gradio-4.44.0-py3-None-any.whl.metadata (15 kB)\nRequirement already satisfied: aiofiles<24.0,>=22.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (22.1.0)\nRequirement already satisfied: anyio<5.0,>=3.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (4.4.0)\nRequirement already satisfied: fastapi<1.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.111.0)\nCollecting ffmpy (from gradio)\n Downloading ffmpy-0.4.0-py3-None-any.whl.metadata (2.9 kB)\nCollecting gradio-client==1.3.0 (from gradio)\n Downloading gradio_client-1.3.0-py3-None-any.whl.metadata (7.1 kB)\nRequirement already satisfied: httpx>=0.24.1 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.27.0)\nRequirement already satisfied: huggingface-hub>=0.19.3 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.24.6)\nRequirement already satisfied: importlib-resources<7.0,>=1.3 in /opt/conda/lib/python3.10/site-packages (from gradio) (6.4.0)\nRequirement already satisfied: jinja2<4.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (3.1.4)\nRequirement already satisfied: markupsafe~=2.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.1.5)\nRequirement already satisfied: matplotlib~=3.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (3.7.5)\nRequirement already satisfied: numpy<3.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (1.26.4)\nRequirement already satisfied: orjson~=3.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (3.10.4)\nRequirement already satisfied: packaging in /opt/conda/lib/python3.10/site-packages (from gradio) (21.3)\nRequirement already satisfied: pandas<3.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.2.2)\nRequirement already satisfied: pillow<11.0,>=8.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (9.5.0)\nRequirement already satisfied: pydantic>=2.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.8.2)\nRequirement already satisfied: pydub in /opt/conda/lib/python3.10/site-packages (from gradio) (0.25.1)\nRequirement already satisfied: python-multipart>=0.0.9 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.0.9)\nRequirement already satisfied: pyyaml<7.0,>=5.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (6.0.2)\nCollecting ruff>=0.2.2 (from gradio)\n Downloading ruff-0.6.4-py3-None-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\nCollecting semantic-version~=2.0 (from gradio)\n Downloading semantic_version-2.10.0-py2.py3-None-any.whl.metadata (9.7 kB)\nCollecting tomlkit==0.12.0 (from gradio)\n Downloading tomlkit-0.12.0-py3-None-any.whl.metadata (2.7 kB)\nRequirement already satisfied: typer<1.0,>=0.12 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.12.3)\nRequirement already satisfied: typing-extensions~=4.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (4.12.2)\nCollecting urllib3~=2.0 (from gradio)\n Downloading urllib3-2.2.3-py3-None-any.whl.metadata (6.5 kB)\nRequirement already satisfied: uvicorn>=0.14.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.30.1)\nRequirement already satisfied: fsspec in /opt/conda/lib/python3.10/site-packages (from gradio-client==1.3.0->gradio) (2024.6.1)\nRequirement already satisfied: websockets<13.0,>=10.0 in /opt/conda/lib/python3.10/site-packages (from gradio-client==1.3.0->gradio) (12.0)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (3.7)\nRequirement already satisfied: sniffio>=1.1 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (1.2.0)\nRequirement already satisfied: starlette<0.38.0,>=0.37.2 in /opt/conda/lib/python3.10/site-packages (from fastapi<1.0->gradio) (0.37.2)\nRequirement already satisfied: fastapi-cli>=0.0.2 in /opt/conda/lib/python3.10/site-packages (from fastapi<1.0->gradio) (0.0.4)\nRequirement already satisfied: ujson!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,>=4.0.1 in /opt/conda/lib/python3.10/site-packages (from fastapi<1.0->gradio) (5.10.0)\nRequirement already satisfied: email_validator>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from fastapi<1.0->gradio) (2.1.1)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx>=0.24.1->gradio) (2024.7.4)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx>=0.24.1->gradio) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\nRequirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (3.15.1)\nRequirement already satisfied: requests in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\nRequirement already satisfied: tqdm>=4.42.1 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (4.66.4)\nRequirement already satisfied: contourpy>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (1.2.1)\nRequirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (0.12.1)\nRequirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (4.53.0)\nRequirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (1.4.5)\nRequirement already satisfied: pyparsing>=2.3.1 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (3.1.2)\nRequirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (2.9.0.post0)\nRequirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\nRequirement already satisfied: tzdata>=2022.7 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\nRequirement already satisfied: annotated-types>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (0.7.0)\nRequirement already satisfied: pydantic-core==2.20.1 in /opt/conda/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (2.20.1)\nRequirement already satisfied: click>=8.0.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\nRequirement already satisfied: shellingham>=1.3.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\nRequirement already satisfied: rich>=10.11.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (13.7.1)\nRequirement already satisfied: dnspython>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from email_validator>=2.0.0->fastapi<1.0->gradio) (2.6.1)\nRequirement already satisfied: six>=1.5 in /opt/conda/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\nRequirement already satisfied: markdown-it-py>=2.2.0 in /opt/conda/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\nRequirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/conda/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\nRequirement already satisfied: httptools>=0.5.0 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]>=0.12.0->fastapi<1.0->gradio) (0.6.1)\nRequirement already satisfied: python-dotenv>=0.13 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]>=0.12.0->fastapi<1.0->gradio) (1.0.1)\nRequirement already satisfied: uvloop!=0.15.0,!=0.15.1,>=0.14.0 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]>=0.12.0->fastapi<1.0->gradio) (0.19.0)\nRequirement already satisfied: watchfiles>=0.13 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]>=0.12.0->fastapi<1.0->gradio) (0.22.0)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\nRequirement already satisfied: mdurl~=0.1 in /opt/conda/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\nDownloading gradio-4.44.0-py3-None-any.whl (18.1 MB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.1/18.1 MB\u001b[0m \u001b[31m58.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n\u001b[?25hDownloading gradio_client-1.3.0-py3-None-any.whl (318 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m318.7/318.7 kB\u001b[0m \u001b[31m14.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading tomlkit-0.12.0-py3-None-any.whl (37 kB)\nDownloading ruff-0.6.4-py3-None-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.3 MB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.3/10.3 MB\u001b[0m \u001b[31m76.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m0:01\u001b[0m\n\u001b[?25hDownloading semantic_version-2.10.0-py2.py3-None-any.whl (15 kB)\nDownloading urllib3-2.2.3-py3-None-any.whl (126 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m126.3/126.3 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading ffmpy-0.4.0-py3-None-any.whl (5.8 kB)\nInstalling collected packages: urllib3, tomlkit, semantic-version, ruff, ffmpy, gradio-client, gradio\n Attempting uninstall: urllib3\n Found existing installation: urllib3 1.26.18\n Uninstalling urllib3-1.26.18:\n Successfully uninstalled urllib3-1.26.18\n Attempting uninstall: tomlkit\n Found existing installation: tomlkit 0.13.2\n Uninstalling tomlkit-0.13.2:\n Successfully uninstalled tomlkit-0.13.2\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\nkfp 2.5.0 requires urllib3<2.0.0, but you have urllib3 2.2.3 which is incompatible.\nydata-profiling 4.9.0 requires scipy<1.14,>=1.4.1, but you have scipy 1.14.0 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed ffmpy-0.4.0 gradio-4.44.0 gradio-client-1.3.0 ruff-0.6.4 semantic-version-2.10.0 tomlkit-0.12.0 urllib3-2.2.1\nRunning on local URL: http://127.0.0.1:7860\nKaggle notebooks require sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n\nRunning on public URL: https://5b6de83aa5bb88d174.gradio.live\n\nThis share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"<div><iframe src=\"https://5b6de83aa5bb88d174.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"},"metadata":{}},{"execution_count":45,"output_type":"execute_result","data":{"text/plain":""},"metadata":{}}]},{"cell_type":"code","source":"","metadata":{},"execution_count":None,"outputs":[]}]}