MOVIE RATING PREDICTION WITH PYTHON¶

Objective :¶

  • Build a model that predicts the rating of a movie based on features like genre, director, and actors. You can use regression techniques to tackle this problem.
  • The goal is to analyze historical movie data and develop a model that accurately estimates the rating given to a movie by users or critics.
  • Movie Rating Prediction project enables you to explore data analysis, preprocessing, feature engineering, and machine learning modeling techniques. It provides insights into the factors that influence movie ratings and allows you to build a model that can estimate the ratings of movies accurately.

Step 1¶

In [47]:
#importing required libraries 
import pandas as pd
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
import plotly.graph_objects as go
import plotly.express as px
from collections import namedtuple
#import ydata_profiling as pandas_profiling  # Use ydata_profiling instead of pandas_profiling
from IPython.display import display

Import the Dataset¶

In [48]:
pwd
Out[48]:
'/Users/mac/Downloads'
In [49]:
ls
0-positive_or_negative
1-main.c.swp
100-elf_header.c.swp
1105+Csot+of+Capital+Debt+Equity+Financing+Overview.pdf
13D1E18F-7BC9-401B-9FB7-C0F83E6E2A0E.JPG
2.jpg
264C02B8-AED2-4225-8907-D7FEA3C94A6A.MP4
2F4EC8AA-EDC9-4518-B605-6A7637FE8FAB.MP4
2fa.blade.php
317972BE-05EB-4474-A090-AA44AB5C9FD7 2.MP4
317972BE-05EB-4474-A090-AA44AB5C9FD7.MP4
39F6D20F-AA06-4189-B18E-8F24E6F9A936.JPG
3b4c0290-d241-4f20-9d31-dbfcf0f9c019.JPG
43e6cb6d-45b9-4cd6-a728-21e5a9e3e290.MP4
5212F45F-DAF9-4553-A98E-B2EE44BAE0CD.JPG
55B33D23-531C-4452-B1E1-D77C0C39969F.MP4
6aa22546944843e78a55c3d5d642ca71.MOV
706E5690-1FF8-457C-8D02-A210C0D2BFC1.MP4
74CE36B5-4D56-45D0-A585-08A9CACB32E4.heic
765ff034-5c16-4a23-963c-de38732274ba.JPG
770F2843-F38C-4184-A071-942D22D593BD.MP4
7c61695b-618e-40a7-b9b9-80e4f2c27edf.MP4
7ee52256-e42c-4420-b4f9-2ad99f557077.jpg
90A1C018-DD37-491D-8B47-8CE6B91897FF.MP4
92CBCB92-405E-4FCF-A149-809B62F1ABBE.MP4
94196546-39c0-4dd1-b432-38830eab04d7.JPG
9e348148-43ac-4baa-8cfd-204816559bf3.MP4
A4394FFD-1836-46F9-9E7C-939CD8F917D9.MP4
A99DE8F2-E261-45E1-91D1-09AA3ED2797E.MP4
Analysis with Missing Data (1).pdf
Analysis with Missing Data.pdf
Ant-Man and the Wasp Quantumania (2023) (NetNaija.com).mkv
Application-for-benefit-payment.pdf
Asset-2pamm-trade-logo (1).png
Asset-2pamm-trade-logo (2).png
Asset-2pamm-trade-logo.png
B41FE178-3B44-4B96-890A-1C19F300ACF0.MP4
B75E9C94-1C4A-4A16-BA65-07C344576D2A.JPG
Bloody.Heart.E03.(NKIRI.COM).pvomndfibiofiogfbnoinbbfgnh.mkv
Bloody.Heart.E04.(NKIRI.COM).nionvfdonoignbofnofignboioifbbg.mkv
Bloody.Heart.E05.(NKIRI.COM).niovdnfoibnofgnboingbonfiggbf.mkv
Bloody.Heart.E06.(NKIRI.COM). nivofoinoinbgoiiogboigfbgb.mkv
Bloody.Heart.E08.(NKIRI.COM).buvfdbuidfibudfibudfuibfvbuifv.mkv
Bloody.Heart.E09.(NKIRI.COM).niovfndovinboigfnbogfbnofgnb.mkv
Bloody.Heart.E11.(NKIRI.COM).nvionfvdfoibnogbnogfnbg.mkv
Bloody.Heart.E12.(NKIRI.COM).novnfdoiboigniobfgniobgiob.mkv
Bloody.Heart.E13.(NKIRI.COM).nvndfobnfognboifngobnifgb.mkv
Bloody.Heart.E14.(NKIRI.COM).niovdnoibnognbofgnbofigb.mkv
Bloody.Hearts.E16.(NKIRI.COM).niovfnindfonbogfnogfbbgfhn.mkv
C20C55A6-842E-4AD0-BB22-FAD3241005FD.MP4
C525AE24-D714-449B-B46A-7D1ADE53B950.MP4
C9B9EE5E-EC82-41A6-8D6F-684A52759F7C.MP4
CHM501.pdf
CSSMasterclassBook.pdf
Chapter7Sound.m4a
D19EF259-9AAB-4FF2-A33C-ED44D9FF11E5.MP4
D2B45082-5E66-44D7-A885-78301BE943E0.MP4
D2E27492-096A-47DE-B7D6-06D862749176.MP4
D8AAF82C-3C44-4405-AF41-106BCD7ED647.MP4
DA PROJECTS.pdf
DATA SCIENCE (3) (1).pdf
DATA SCIENCE (3).pdf
DATABASE_Nov2021.sql
DATABASE_Nov2021.zip
DE3817F4-B0FF-4662-9786-49575DFC2BCE.MP4
Data Science Week 2 Case Study.py
Dataset MeriSKILL (1).zip
Dataset MeriSKILL.zip
Devolutions.RemoteDesktopManager.Mac.2023.2.10.7.dmg
E653D04C-3828-40F3-ABD9-C1772FEC28F5.MP4
Excess Shopify Theme v1.0/
Excess Shopify Theme v1.0.zip
Excess-Watch-Shop-Shopify-Theme.zip
ExpressZip_i.dmg
F11AE88D-1529-4E14-8F42-374068AFEA09.JPG
F5C9B15E-FE46-4658-B1CF-878D5AF3891F.MP4
FACE.jpeg
FEBDDCDE-418A-4D61-AB55-D64EEE729FB7 2.MP4
FEBDDCDE-418A-4D61-AB55-D64EEE729FB7.MP4
FFD772BA-F290-4D16-90CD-0602F5B40D31.JPG
FINAL YEAR PROJECT.docx
FaceAnimator_tutor.webm
Fliqlo 1.8.5 (1).dmg
Fliqlo 1.8.5.dmg
Forex script and database/
Forex script and database.zip
Forex-Trading-Strategies-1.jpg
GitHubDesktop-x64.zip
HR Data.xlsx
ICH 503.pdf
ICH 505 (MINERAL PROCESSING) II.pdf
ICH501.pdf
IMDB-Movie-Data.csv
IMDb Movies India 2.csv
IMDb Movies India 3.csv
IMDb Movies India 4.csv
IMDb Movies India 5.csv
IMDb Movies India 6.csv
IMDb Movies India 7.csv
IMDb Movies India.csv
IMDb Movies India.csv.zip
IMG_0247 2.HEIC
IMG_0247.HEIC
IMG_0248 2.HEIC
IMG_0248.HEIC
IMG_0249 2.HEIC
IMG_0249.HEIC
IMG_0250 2.HEIC
IMG_0250.HEIC
IMG_0251 2.HEIC
IMG_0251.HEIC
IMG_0252 2.HEIC
IMG_0252.HEIC
IMG_0254 2.HEIC
IMG_0254.HEIC
IMG_0255 2.HEIC
IMG_0255.HEIC
IMG_0256 2.HEIC
IMG_0256.HEIC
IMG_0257 2.HEIC
IMG_0257.HEIC
IMG_0258 2.HEIC
IMG_0258.HEIC
IMG_0259 2.HEIC
IMG_0259.HEIC
IMG_0260 2.HEIC
IMG_0260.HEIC
IMG_0262 2.HEIC
IMG_0262.HEIC
IMG_0263 2.HEIC
IMG_0263.HEIC
IMG_0264 2.HEIC
IMG_0264.HEIC
IMG_0265 2.HEIC
IMG_0265.HEIC
IMG_0266 2.HEIC
IMG_0266.HEIC
IMG_0267 2.HEIC
IMG_0267.HEIC
IMG_0268 2.HEIC
IMG_0268.HEIC
IMG_0269 2.HEIC
IMG_0269.HEIC
IMG_0270 2.HEIC
IMG_0270.HEIC
IMG_0271 2.HEIC
IMG_0271.HEIC
IMG_0272 2.HEIC
IMG_0272.HEIC
IMG_0273 2.HEIC
IMG_0273.HEIC
IMG_0274 2.HEIC
IMG_0274.HEIC
IMG_0275 2.HEIC
IMG_0275.HEIC
IMG_0276 2.HEIC
IMG_0276.HEIC
IMG_0277 2.HEIC
IMG_0277.HEIC
IMG_0279 2.HEIC
IMG_0279.HEIC
IMG_0283 2.HEIC
IMG_0283.HEIC
IMG_0284 2.HEIC
IMG_0284.HEIC
IMG_0285 2.HEIC
IMG_0285.HEIC
IMG_0288 2.HEIC
IMG_0288.HEIC
IMG_0289 2.HEIC
IMG_0289.HEIC
IMG_0290 2.HEIC
IMG_0290.HEIC
IMG_0291 2.HEIC
IMG_0291.HEIC
IMG_0292 2.HEIC
IMG_0292.HEIC
IMG_0293 2.HEIC
IMG_0293.HEIC
IMG_0294 2.HEIC
IMG_0294.HEIC
IMG_0295 2.HEIC
IMG_0295.HEIC
IMG_0296 2.HEIC
IMG_0296.HEIC
IMG_0297 2.HEIC
IMG_0297.HEIC
IMG_0298 2.HEIC
IMG_0298.HEIC
IMG_0299 2.HEIC
IMG_0299.HEIC
IMG_0300 2.HEIC
IMG_0300.HEIC
IMG_0301 2.HEIC
IMG_0301.HEIC
IMG_0302 2.HEIC
IMG_0302.HEIC
IMG_0303 2.HEIC
IMG_0303.HEIC
IMG_0426.HEIC
IMG_0480 2.HEIC
IMG_0480.HEIC
IMG_0513 2.HEIC
IMG_0513.HEIC
IMG_0514 2.HEIC
IMG_0514.HEIC
IMG_0515 2.HEIC
IMG_0515.HEIC
IMG_0516 2.HEIC
IMG_0516.HEIC
IMG_0517 2.HEIC
IMG_0517.HEIC
IMG_0518 2.HEIC
IMG_0518.HEIC
IMG_0519 2.HEIC
IMG_0519.HEIC
IMG_0520 2.HEIC
IMG_0520.HEIC
IMG_0521 2.HEIC
IMG_0521.HEIC
IMG_0522 2.HEIC
IMG_0522.HEIC
IMG_0523 2.HEIC
IMG_0523.HEIC
IMG_0524 2.HEIC
IMG_0524.HEIC
IMG_0525 2.HEIC
IMG_0525.HEIC
IMG_1094.heic
IMG_1095.heic
IMG_1096.heic
IMG_1097.heic
IMG_1098.heic
IMG_1099.heic
IMG_1100.heic
IMG_1551.JPG
IMG_1552.heic
IMG_1553.HEIC
IMG_1554.heic
IMG_1555.heic
IMG_1556.heic
IMG_1557.heic
IMG_1558.heic
IMG_1559.heic
IMG_1560.heic
IMG_1561.heic
IMG_1562.heic
IMG_1563.HEIC
IMG_1564.heic
IMG_1565.heic
IMG_1566.heic
IMG_1567.HEIC
IMG_1568.heic
IMG_1569.heic
IMG_1570.heic
IMG_1571.heic
IMG_1572.HEIC
IMG_1573.HEIC
IMG_1574.HEIC
IMG_1575.HEIC
IMG_1576.HEIC
IMG_1577.HEIC
IMG_1578.heic
IMG_1579.heic
IMG_1580.heic
IMG_1581.heic
IMG_1582.HEIC
IMG_1583.HEIC
IMG_1586.HEIC
IMG_1587.HEIC
IMG_1592.HEIC
IMG_1593.HEIC
IMG_1678.HEIC
IMG_1679.HEIC
IMG_1680.HEIC
IMG_1709.heic
IMG_1710.HEIC
IMG_1711.HEIC
IMG_1712.HEIC
IMG_1713.HEIC
IMG_1714.HEIC
IMG_1715.HEIC
IMG_1721.HEIC
IMG_1736.HEIC
IMG_1737.HEIC
IMG_1738.HEIC
IMG_1739.HEIC
IMG_1740.HEIC
IMG_1741.HEIC
IMG_1742.HEIC
IMG_1743.HEIC
IMG_1810.HEIC
IMG_1811.HEIC
IMG_1812.HEIC
IMG_1813.HEIC
IMG_1814.HEIC
IMG_1828.HEIC
IMG_1829.HEIC
IMG_1830.HEIC
IMG_1831.HEIC
IMG_1832.HEIC
IMG_1833.HEIC
IMG_1834.HEIC
IMG_1835.HEIC
IMG_1836.HEIC
IMG_1837.HEIC
IMG_1838.HEIC
IMG_1839.PNG
IMG_1840.jpg
IMG_1893.HEIC
IMG_1904.HEIC
IMG_1905.HEIC
IMG_1906.HEIC
IMG_1907.HEIC
IMG_1908.HEIC
IMG_1909.HEIC
IMG_1910.HEIC
IMG_1911.HEIC
IMG_1912.HEIC
IMG_1945.heic
IMG_1946.HEIC
IMG_1947.HEIC
IMG_1948.heic
IMG_1949.HEIC
IMG_1950.HEIC
IMG_1951.HEIC
IMG_1952.HEIC
IMG_1953.HEIC
IMG_1954.HEIC
IMG_1955.HEIC
IMG_1956.HEIC
IMG_1957.HEIC
IMG_1958.HEIC
IMG_1959.HEIC
IMG_1960.HEIC
IMG_1961.HEIC
IMG_1962.HEIC
IMG_1963.heic
IMG_1964.heic
IMG_1965.heic
IMG_1966.heic
IMG_1967.heic
IMG_1968.heic
IMG_1969.heic
IMG_1970.heic
IMG_1971.heic
IMG_1972.heic
IMG_1973.heic
IMG_1996.HEIC
IMG_1997.HEIC
IMG_1998.HEIC
IMG_1999.HEIC
IMG_2001 2.HEIC
IMG_2001.HEIC
IMG_2002.HEIC
IMG_2003.HEIC
IMG_2004.HEIC
IMG_2005.HEIC
IMG_2006.HEIC
IMG_2007.heic
IMG_2008.HEIC
IMG_2013.HEIC
IMG_2014.HEIC
IMG_2018.HEIC
IMG_2020.heic
IMG_2021.heic
IMG_2022.heic
IMG_2025.heic
IMG_2056 2.HEIC
IMG_2056.heic
IMG_2057.heic
IMG_2058.heic
IMG_2068.heic
IMG_2069 2.HEIC
IMG_2069.heic
IMG_2070.heic
IMG_2071 2.HEIC
IMG_2071.heic
IMG_2072.heic
IMG_2073 2.HEIC
IMG_2073.heic
IMG_2074.heic
IMG_2080.heic
IMG_2081.heic
IMG_2082.HEIC
IMG_2083.HEIC
IMG_2084.HEIC
IMG_2085.heic
IMG_2086.heic
IMG_2087 2.HEIC
IMG_2087.heic
IMG_2088.heic
IMG_2089.heic
IMG_2090.heic
IMG_2091.heic
IMG_2092.heic
IMG_2107.heic
IMG_2108.heic
IMG_2109.heic
IMG_2110.heic
IMG_2111.heic
IMG_2112.heic
IMG_2116.heic
IMG_2117.heic
IMG_2123.heic
IMG_2124.heic
IMG_2125.heic
IMG_2126.heic
IMG_2127.heic
IMG_2128.heic
IMG_2129.heic
IMG_2130.heic
IMG_2131.HEIC
IMG_2132.heic
IMG_2133.heic
IMG_2134.HEIC
IMG_2135.HEIC
IMG_2136.HEIC
IMG_2137.HEIC
IMG_2138.HEIC
IMG_2139.HEIC
IMG_2162.heic
IMG_2163.heic
IMG_2164.heic
IMG_2165.heic
IMG_2166.heic
IMG_2167.heic
IMG_2168.heic
IMG_2169.heic
IMG_2170.heic
IMG_2173.heic
IMG_2180.heic
IMG_2181.heic
IMG_2182.heic
IMG_2183.heic
IMG_2184.heic
IMG_2185.heic
IMG_2186.heic
IMG_2187.heic
IMG_2188.heic
IMG_2189.heic
IMG_2190.heic
IMG_2191.heic
IMG_2192.heic
IMG_2196.heic
IMG_2197.heic
IMG_2213.PNG
IMG_2245.HEIC
IMG_2247.HEIC
IMG_2254.PNG
IMG_2256.jpg
IMG_2257.JPG
IMG_2258.PNG
IMG_2259.PNG
IMG_2261.jpg
IMG_2262.jpg
IMG_2263.jpg
IMG_2264.PNG
IMG_2265.jpg
IMG_2266.PNG
IMG_2267.PNG
IMG_2269.PNG
IMG_2270.jpg
IMG_2271.jpg
IMG_2272.PNG
IMG_2278.DNG
IMG_2279.DNG
IMG_2280.DNG
IMG_2282.JPG
IMG_2283.JPG
IMG_2284.JPG
IMG_2285.MOV
IMG_2286.JPG
IMG_2287.MOV
IMG_2288.MOV
IMG_2289.MOV
IMG_2290.MOV
IMG_2291.MOV
IMG_2292.HEIC
IMG_2293.HEIC
IMG_2294.HEIC
IMG_2295.heic
IMG_2297.HEIC
IMG_2298.HEIC
IMG_2302.HEIC
IMG_2303.HEIC
IMG_2304.HEIC
IMG_2310.HEIC
IMG_2311.HEIC
IMG_2314.heic
IMG_2315.HEIC
IMG_2316.HEIC
IMG_2317.heic
IMG_2318.heic
IMG_2319.MOV
IMG_2319.heic
IMG_2320.heic
IMG_2321.heic
IMG_2322.heic
IMG_2323.heic
IMG_2324.heic
IMG_2325.heic
IMG_2334.heic
IMG_2335.heic
IMG_2336.heic
IMG_2338.heic
IMG_2339.heic
IMG_2340.heic
IMG_2341.heic
IMG_2342.heic
IMG_2343.heic
IMG_2346.PNG
IMG_2347.heic
IMG_2348.heic
IMG_2349.heic
IMG_2350.heic
IMG_2351.heic
IMG_2352.heic
IMG_2353.heic
IMG_2354.heic
IMG_2355.heic
IMG_2356.heic
IMG_2357.heic
IMG_2358.HEIC
IMG_2359.HEIC
IMG_2360.HEIC
IMG_2361.HEIC
IMG_2362.HEIC
IMG_2363.heic
IMG_2364.heic
IMG_2365.heic
IMG_2366.heic
IMG_2367.heic
IMG_2368.heic
IMG_2369.heic
IMG_2370.heic
IMG_2371.heic
IMG_2372.heic
IMG_2373.heic
IMG_2374.heic
IMG_2375.heic
IMG_2376.heic
IMG_2377.heic
IMG_2378.heic
IMG_2379.heic
IMG_2380.heic
IMG_2381.heic
IMG_2382.heic
IMG_2383.heic
IMG_2384.HEIC
IMG_2385.heic
IMG_2386.HEIC
IMG_2387.heic
IMG_2388.heic
IMG_2389.heic
IMG_2390.heic
IMG_2391.heic
IMG_2392.heic
IMG_2393.heic
IMG_2394.heic
IMG_2395.heic
IMG_2396.heic
IMG_2397.heic
IMG_2398.heic
IMG_2399.heic
IMG_2400.heic
IMG_2401.heic
IMG_2402.heic
IMG_2403.heic
IMG_2404.heic
IMG_2405.heic
IMG_2406.heic
IMG_2407.heic
IMG_2408.heic
IMG_2409.heic
IMG_2410.HEIC
IMG_2411.heic
IMG_2412.heic
IMG_2413.heic
IMG_2414.HEIC
IMG_2415.heic
IMG_2416.heic
IMG_2417.heic
IMG_2418.heic
IMG_2419.heic
IMG_2420.heic
IMG_2421.heic
IMG_2422.heic
IMG_2423.heic
IMG_2424.heic
IMG_2425.heic
IMG_2428.MOV
IMG_2438.HEIC
IMG_2439.HEIC
IMG_2440.HEIC
IMG_2441.HEIC
IMG_2448.MOV
IMG_2449.HEIC
IMG_2449.MOV
IMG_2450.MOV
IMG_2451.PNG
IMG_3308 (1).ico
IMG_3308 (1).png
IMG_3308.ico
IMG_3308.jpg
IMG_4730.HEIC
IMG_4731.HEIC
IMG_4732.HEIC
IMG_4733.HEIC
IMG_4734.HEIC
IMG_4735.heic
IMG_4736.HEIC
IMG_4737.HEIC
IMG_4738.HEIC
IMG_4739.HEIC
IMG_4749.HEIC
IMG_4750.HEIC
IMG_4751.HEIC
IMG_4752.HEIC
IMG_4753.HEIC
IMG_4754.HEIC
IMG_4755.HEIC
IMG_4756.HEIC
IMG_4757.HEIC
IMG_4758.HEIC
IMG_4759.HEIC
IMG_4760.HEIC
IMG_4761.HEIC
IMG_4762.HEIC
IMG_4763.HEIC
IMG_4764.HEIC
IMG_4765.HEIC
IMG_4766.HEIC
IMG_4767.HEIC
IMG_4768.HEIC
IMG_4769.HEIC
IMG_4770.HEIC
IMG_4771.HEIC
IMG_4772.HEIC
IMG_4773.HEIC
IMG_4774.HEIC
IMG_4775.HEIC
IMG_4776.HEIC
IMG_4777.HEIC
IMG_4778.HEIC
IMG_4779.HEIC
IMG_4780.HEIC
IMG_4781.HEIC
IMG_4782.HEIC
IMG_4783.HEIC
IMG_4784.HEIC
IMG_4785.HEIC
IMG_4786.HEIC
IMG_4788.heic
IMG_4789.heic
IMG_4790.heic
IMG_4791.heic
IMG_4792.HEIC
IMG_4793.HEIC
IMG_4794.HEIC
IMG_4795.HEIC
IMG_4796.HEIC
IMG_4797.HEIC
IMG_4803.HEIC
IMG_4804.HEIC
IMG_4805.HEIC
IMG_4807.HEIC
IMG_4808.HEIC
IMG_4809.HEIC
IMG_4810.HEIC
IMG_4811.HEIC
IMG_4812.HEIC
IMG_4813.HEIC
IMG_4814.HEIC
IMG_4815.HEIC
IMG_4816.HEIC
IMG_4817.HEIC
IMG_4818.HEIC
IMG_4819.HEIC
IMG_4820.HEIC
IMG_4821.HEIC
IMG_4822.HEIC
IMG_4823.HEIC
IMG_4824.HEIC
IMG_4825.HEIC
IMG_4826.HEIC
IMG_4827.HEIC
IMG_4828.HEIC
IMG_4829.HEIC
IMG_4830.HEIC
IMG_4833.HEIC
IMG_4834.HEIC
IMG_4835.HEIC
IMG_4836.HEIC
IMG_4837.HEIC
IMG_4841.HEIC
IMG_4842.HEIC
IMG_4843.HEIC
IMG_4844.HEIC
IMG_4845.HEIC
IMG_4846.HEIC
IMG_4847.HEIC
IMG_4854.HEIC
IMG_4855.HEIC
IMG_4856.HEIC
IMG_4857.HEIC
IMG_4858.HEIC
IMG_4859.HEIC
IMG_4860.HEIC
IMG_4861.HEIC
IMG_4862.HEIC
IMG_4863.HEIC
IMG_4864.HEIC
IMG_4865.HEIC
IMG_4868.HEIC
IMG_4869.HEIC
IMG_4870.HEIC
IMG_4871.HEIC
IMG_4872.HEIC
IMG_4873.HEIC
IMG_4874.HEIC
IMG_4875.HEIC
IMG_4876.HEIC
IMG_4877.HEIC
IMG_4878.HEIC
IMG_4879.HEIC
IMG_4880.HEIC
IMG_4881.HEIC
IMG_4882.HEIC
IMG_4883.HEIC
IMG_4884.HEIC
IMG_4885.HEIC
IMG_4886.HEIC
IMG_4887.HEIC
IMG_4888.HEIC
IMG_4889.HEIC
IMG_4890.HEIC
IMG_4891.HEIC
IMG_4892.HEIC
IMG_4893.HEIC
IMG_4894.HEIC
IMG_4895.HEIC
IMG_4896.HEIC
IMG_4897.heic
IMG_4898.HEIC
IMG_4899.HEIC
IMG_4900.HEIC
IMG_4901.HEIC
IMG_4902.HEIC
IMG_4903.HEIC
IMG_4904.HEIC
IMG_4905.HEIC
IMG_4906.HEIC
IMG_4907.HEIC
IMG_4908.HEIC
IMG_4909.HEIC
IMG_4910.HEIC
IMG_4911.HEIC
IMG_4912.HEIC
IMG_4913.HEIC
IMG_4914.HEIC
IMG_4915.HEIC
IMG_4916.HEIC
IMG_4917.HEIC
IMG_4918.HEIC
IMG_4919.HEIC
IMG_4920.HEIC
IMG_4921.HEIC
IMG_4922.HEIC
IMG_4923.HEIC
IMG_4924.HEIC
IMG_4925.HEIC
IMG_4926.HEIC
IMG_4927.HEIC
IMG_4928.HEIC
IMG_4929.HEIC
IMG_5658.HEIC
IMG_5659.HEIC
IMG_6922.PNG
IMG_6923.PNG
IMG_6924.PNG
IMG_6925.PNG
IMG_6926.PNG
IMG_6929.jpg
IMG_7497 2.HEIC
IMG_7497 3.HEIC
IMG_7497.HEIC
IMG_7498 2.jpg
IMG_7498.jpg
IMG_8637.heic
IMG_8638.heic
IMG_8639.HEIC
IMG_8640.HEIC
IMG_8641.HEIC
IMG_8642.HEIC
IMG_8643.HEIC
IMG_8644.HEIC
IMG_8645.HEIC
IMG_8646.heic
IMG_8903.MOV
InterimStmt_20221230.pdf
MXPlayer/
Mozilla_Firefox_for_Mac_v110.0.1.dmg
NayyarShaikh-Resido.zip
Nicepage-4.17.10.dmg
OnlineTrade/
OnlineTrade.zip
Opera Installer.app/
OperaSetup.zip
PASS.jpeg
PP.jpeg
PSDD.jpeg
PaySlip20221229.pdf
Pixillion_i.dmg
Plan.html
Project 2 MeriSKILL.zip
Project+Files/
Project+Files 2/
Project+Files.zip
RPReplay_Final1666895608.MP4
RPReplay_Final1666897024.MP4
RPReplay_Final1666897827.MP4
RPReplay_Final1666900352.MP4
RPReplay_Final1674080656.MP4
RPReplay_Final1674081589.MP4
RPReplay_Final1674081668.MP4
RPReplay_Final1674082334.MP4
RPReplay_Final1674082751.MP4
Redwood-Financial-Summer-Profile-007-1024x1024.jpg
School Manager.pdf
Seotech Free Website Template - Free-CSS.com.zip
Spider-Man Across the Spider-Verse (2023) (NetNaija.com).mkv
The Diabetic Analysis Data (1).ipynb
The Diabetic Analysis Data.html
The Diabetic Analysis Data.ipynb
The Three Musketeers D'Artagnan (2023) (NetNaija.com).mkv
Titanic Survival Prediction Project.ipynb
TradeFrontend/
TradeFrontend.zip
TransferReceipt.jpg
True Life Bank (1).png
True Life Bank.png
Unconfirmed 274505.crdownload
VISA DIGITAL BANK/
VISA DIGITAL BANK (1)/
VISA DIGITAL BANK (1).zip
VISA DIGITAL BANK.zip
VSCode-darwin-universal.zip
VirtualBox-6.1.38-153438-OSX.dmg
WE.jpeg
WWU.avif
Week 1 Case Study  Managing Student Information .html
Week 1 Case Study  Managing Student Information .ipynb
Week 1 Case Study  Managing Student Information .md
Week 1 Case Study  Managing Student Information .py
WhatsApp-2.23.23.82.dmg
Windscribe_2.6.14.dmg
Yourreceipt._20221229.pdf
[Waploaded_34169]_American_Psycho_2000.mp4
_Sales Data Analysis.html
_Sales Data Analysis.py
a108a738-b8b3-4c7d-bcca-ba795141f797 2.JPG
a108a738-b8b3-4c7d-bcca-ba795141f797.JPG
a3c81cf5-bbdb-496d-b542-c043af881d44.JPG
a6443022-2a93-408e-9bee-e15b44965874.JPG
about.jpeg
account-setupabf8.svg
aman-150x150.jpg
archbb/
archbb.zip
archive (1).zip
archive (2).zip
archive (3).zip
archive (4).zip
archive (5).zip
archive (6).zip
archive (6).zip.crdownload
archive (7).zip
archive (8).zip
archive.zip
b10d1ce0-273a-49e1-ac00-dd09b7aaf87b 2.jpg
b10d1ce0-273a-49e1-ac00-dd09b7aaf87b.JPG
b617a8d4-a96e-4b12-9bc6-9fcaf82dca9e.MP4
banner-forex-chart.jpg
beam 2.zip
beam.zip
beambtc.zip
bitbank-main.zip
c85c3f4c-7518-4b1b-8cec-55c134dee901.MP4
cat.webp
cb9d72f4-a287-4c54-ae87-127c810c0b7f 2.JPG
cb9d72f4-a287-4c54-ae87-127c810c0b7f.JPG
cdc8d1ca-8ad2-4b60-b689-015cf541a30e.JPG
certificate.pdf
certificate.pdf.zip
chi.html
chima FINAL YEAR PROJECT.docx
config (1).php
config (2).php
config (3).php
config.php
database (1).sql
database (2).sql
database.sql
davinci-resolve-18-6-2.zip.crdownload
deposit-and-withdrawalsc07e.svg
deseekerfarm/
educenter-main/
educenter-main.zip
eth.png
ev3SHRbanner.png1665829328
event.ics
f4d13a4c-1e92-4360-81b6-2ebbdb838af4 2.JPG
f4d13a4c-1e92-4360-81b6-2ebbdb838af4.JPG
favicon (1).png
favicon (2).png
favicon (3).png
favicon.ico
favicon.ico.zip
favicon.png
fifa21 raw data v2.csv
files-WhatsApp.dmg
filtered-64DD2A32-6DCD-439F-BA8B-F15874995F80.MP4
filtered-6732825B-138E-4A0C-B0DE-48E8FDA541CB.MP4
filtered-6FF970EE-E613-4219-B72E-D0B263ECA0DF.MP4
filtered-79597596-DB47-4E60-9D32-91CD81B0D717.MP4
filtered-7A955C1A-F1EE-4A2F-822C-A9FDC2BFFE4F.MP4
filtered-8083C035-08C0-4450-97BC-22FE8C3BBD6D.MP4
filtered-9330A2CF-321D-4C04-95ED-7345D4932A85.MP4
filtered-9A6F6896-7067-4A23-9E07-6E2F420D3966.MP4
filtered-BD580544-8D60-4FAF-B2FD-C1D8C768B541.MP4
filtered-C680DD7A-26FA-425A-A049-A492028695BE.MP4
filtered-D5092A9E-7390-4F12-833D-63D1A0377F43.MP4
filtered-DD8D14E5-9031-4233-930A-672D557EE57A.MP4
filtered-F9761ED2-7AEA-4ADE-B861-E2800DB68D89.MP4
forex_trading_l4mVY5v.width-648.jpg
gettyimages-1136898566-612x612.jpg
gettyimages-1151007900-612x612.jpg
gettyimages-478644475-612x612.jpg
googlechrome.dmg
homewydm_pamdb.sql
htaccess
ico_1_hover.png
ico_3_back.png
ico_4_front.png
in-logo-1.jpeg
index.blade.php
index.php
join.html
jpg2png (1).zip
jpg2png.zip
leverage-trading6d41.svg
libmy.a
live
logo-dark.png
logo.png
logo.png.zip
logo1.jpeg
logo2.jpeg
logs-23-08-29_20-14-21.zip
mac-pdfelement_setup_full5258 (1).dmg
mac-pdfelement_setup_full5258 (2).dmg
mac-pdfelement_setup_full5258 (3).dmg
mac-pdfelement_setup_full5258 (4).dmg
mac-pdfelement_setup_full5258 (5).dmg
mac-pdfelement_setup_full5258 (6).dmg
mac-pdfelement_setup_full5258 (7).dmg
mac-pdfelement_setup_full5258.dmg
main_df
ms-python.python-2022.20.2.vsix
multipass-1.10.1+mac-Darwin.pkg
novena-main.zip
obamacare_profile-150x150.jpg
obs-studio-29.0.0-macos-x86_64.dmg
packages (1).php
packages.php
payslip8022610-5e0d384dc5d7bb3f21891149.pdf
payslip8022646-5e0d384dc5d7bb3f21891149.pdf
payslip8022782-5e0d384dc5d7bb3f21891149.pdf
pia-macos-3.5.1-07760.zip
pixillionmaci.zip*
profit/
pycharm-professional-2023.2.3.dmg
realestate_dataset (1).csv
realestate_dataset.csv
recorded-11059660619287.MP4
recorded-14255235551241.MP4
recorded-16527121614043.MP4
recorded-17717508214893.MP4
recorded-17897558954568.MP4
recorded-4520093265608.MP4
recorded-6596492696396.MP4
recorded-6598737181117.MP4
recorded-6618592962312.MP4
recorded-7891671493068.MP4
sb_scatterplot.jpg
security0a24.svg
seminar power point.docx
seotech-html/
seotech-html.zip
small_df
sublime_text_build_4126_mac.zip
tested 2.csv
tested.csv
theme.zip
themeforest-0Nv3QHtz-profit-forex-and-finance-html-template.zip
titanic (1).csv
trader.jpeg
trading/
trading.zip
unfastlogistics.com-20210616-101055-j40lpd.wpress
unfastlogistics.com-20210616-101055-j40lpd.wpress.zip
userClass (1).php
userClass.php
victor front page.docx
vlc-3.0.18-intel64 (1).dmg
vlc-3.0.18-intel64.dmg
wallet-main.zip
wallet.php
wallpaperflare.com_wallpaper.jpg
wave.jpeg
west.jpeg
work.jpeg
wwww.jpeg
zipfreemaci.zip
In [52]:
df = pd.read_csv('IMDb Movies India 7.csv' ,encoding= 'latin1')
In [53]:
df.head()
Out[53]:
Name Year Duration Genre Rating Votes Director Actor 1 Actor 2 Actor 3
0 NaN NaN Drama NaN NaN J.S. Randhawa Manmauji Birbal Rajendra Bhatia
1 #Gadhvi (He thought he was Gandhi) (2019) 109 min Drama 7.0 8 Gaurav Bakshi Rasika Dugal Vivek Ghamande Arvind Jangid
2 #Homecoming (2021) 90 min Drama, Musical NaN NaN Soumyajit Majumdar Sayani Gupta Plabita Borthakur Roy Angana
3 #Yaaram (2019) 110 min Comedy, Romance 4.4 35 Ovais Khan Prateik Ishita Raj Siddhant Kapoor
4 ...And Once Again (2010) 105 min Drama NaN NaN Amol Palekar Rajat Kapoor Rituparna Sengupta Antara Mali
In [54]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 15509 entries, 0 to 15508
Data columns (total 10 columns):
 #   Column    Non-Null Count  Dtype  
---  ------    --------------  -----  
 0   Name      15509 non-null  object 
 1   Year      14981 non-null  object 
 2   Duration  7240 non-null   object 
 3   Genre     13632 non-null  object 
 4   Rating    7919 non-null   float64
 5   Votes     7920 non-null   object 
 6   Director  14984 non-null  object 
 7   Actor 1   13892 non-null  object 
 8   Actor 2   13125 non-null  object 
 9   Actor 3   12365 non-null  object 
dtypes: float64(1), object(9)
memory usage: 1.2+ MB
In [55]:
#We are changing the datatype for column 'Duration'
df['Duration']= df['Duration'].str.replace('min','').apply(pd.to_numeric)

#changing datatype with some string replacing
df["Votes"]=df["Votes"].replace("$5.16M", 516)
df["Votes"] = pd.to_numeric(df['Votes'].str.replace(',',''))
In [56]:
df.shape
Out[56]:
(15509, 10)
In [57]:
df.describe
Out[57]:
<bound method NDFrame.describe of                                      Name    Year  Duration            Genre  \
0                                             NaN       NaN            Drama   
1      #Gadhvi (He thought he was Gandhi)  (2019)     109.0            Drama   
2                             #Homecoming  (2021)      90.0   Drama, Musical   
3                                 #Yaaram  (2019)     110.0  Comedy, Romance   
4                       ...And Once Again  (2010)     105.0            Drama   
...                                   ...     ...       ...              ...   
15504                 Zulm Ko Jala Doonga  (1988)       NaN           Action   
15505                               Zulmi  (1999)     129.0    Action, Drama   
15506                           Zulmi Raj  (2005)       NaN           Action   
15507                       Zulmi Shikari  (1988)       NaN           Action   
15508                        Zulm-O-Sitam  (1998)     130.0    Action, Drama   

       Rating  Votes            Director           Actor 1  \
0         NaN    NaN       J.S. Randhawa          Manmauji   
1         7.0    8.0       Gaurav Bakshi      Rasika Dugal   
2         NaN    NaN  Soumyajit Majumdar      Sayani Gupta   
3         4.4   35.0          Ovais Khan           Prateik   
4         NaN    NaN        Amol Palekar      Rajat Kapoor   
...       ...    ...                 ...               ...   
15504     4.6   11.0       Mahendra Shah  Naseeruddin Shah   
15505     4.5  655.0          Kuku Kohli      Akshay Kumar   
15506     NaN    NaN          Kiran Thej   Sangeeta Tiwari   
15507     NaN    NaN                 NaN               NaN   
15508     6.2   20.0        K.C. Bokadia        Dharmendra   

                  Actor 2          Actor 3  
0                  Birbal  Rajendra Bhatia  
1          Vivek Ghamande    Arvind Jangid  
2       Plabita Borthakur       Roy Angana  
3              Ishita Raj  Siddhant Kapoor  
4      Rituparna Sengupta      Antara Mali  
...                   ...              ...  
15504       Sumeet Saigal    Suparna Anand  
15505      Twinkle Khanna      Aruna Irani  
15506                 NaN              NaN  
15507                 NaN              NaN  
15508          Jaya Prada      Arjun Sarja  

[15509 rows x 10 columns]>
In [58]:
df
Out[58]:
Name Year Duration Genre Rating Votes Director Actor 1 Actor 2 Actor 3
0 NaN NaN Drama NaN NaN J.S. Randhawa Manmauji Birbal Rajendra Bhatia
1 #Gadhvi (He thought he was Gandhi) (2019) 109.0 Drama 7.0 8.0 Gaurav Bakshi Rasika Dugal Vivek Ghamande Arvind Jangid
2 #Homecoming (2021) 90.0 Drama, Musical NaN NaN Soumyajit Majumdar Sayani Gupta Plabita Borthakur Roy Angana
3 #Yaaram (2019) 110.0 Comedy, Romance 4.4 35.0 Ovais Khan Prateik Ishita Raj Siddhant Kapoor
4 ...And Once Again (2010) 105.0 Drama NaN NaN Amol Palekar Rajat Kapoor Rituparna Sengupta Antara Mali
... ... ... ... ... ... ... ... ... ... ...
15504 Zulm Ko Jala Doonga (1988) NaN Action 4.6 11.0 Mahendra Shah Naseeruddin Shah Sumeet Saigal Suparna Anand
15505 Zulmi (1999) 129.0 Action, Drama 4.5 655.0 Kuku Kohli Akshay Kumar Twinkle Khanna Aruna Irani
15506 Zulmi Raj (2005) NaN Action NaN NaN Kiran Thej Sangeeta Tiwari NaN NaN
15507 Zulmi Shikari (1988) NaN Action NaN NaN NaN NaN NaN NaN
15508 Zulm-O-Sitam (1998) 130.0 Action, Drama 6.2 20.0 K.C. Bokadia Dharmendra Jaya Prada Arjun Sarja

15509 rows × 10 columns

In [59]:
df['Genre'].nunique()
Out[59]:
485
In [60]:
df['Genre'].head()
Out[60]:
0              Drama
1              Drama
2     Drama, Musical
3    Comedy, Romance
4              Drama
Name: Genre, dtype: object
In [61]:
df.Year.unique()
Out[61]:
array([nan, '(2019)', '(2021)', '(2010)', '(1997)', '(2005)', '(2008)',
       '(2012)', '(2014)', '(2004)', '(2016)', '(1991)', '(1990)',
       '(2018)', '(1987)', '(1948)', '(1958)', '(2017)', '(2020)',
       '(2009)', '(2002)', '(1993)', '(1946)', '(1994)', '(2007)',
       '(2013)', '(2003)', '(1998)', '(1979)', '(1951)', '(1956)',
       '(1974)', '(2015)', '(2006)', '(1981)', '(1985)', '(2011)',
       '(2001)', '(1967)', '(1988)', '(1995)', '(1959)', '(1996)',
       '(1970)', '(1976)', '(2000)', '(1999)', '(1973)', '(1968)',
       '(1943)', '(1953)', '(1986)', '(1983)', '(1989)', '(1982)',
       '(1977)', '(1957)', '(1950)', '(1992)', '(1969)', '(1975)',
       '(1947)', '(1972)', '(1971)', '(1935)', '(1978)', '(1960)',
       '(1944)', '(1963)', '(1940)', '(1984)', '(1934)', '(1955)',
       '(1936)', '(1980)', '(1966)', '(1949)', '(1962)', '(1964)',
       '(1952)', '(1933)', '(1942)', '(1939)', '(1954)', '(1945)',
       '(1961)', '(1965)', '(1938)', '(1941)', '(1931)', '(1937)',
       '(2022)', '(1932)', '(1923)', '(1915)', '(1928)', '(1922)',
       '(1917)', '(1913)', '(1930)', '(1926)', '(1914)', '(1924)'],
      dtype=object)
In [62]:
df.Rating.unique()  
Out[62]:
array([ nan,  7. ,  4.4,  4.7,  7.4,  5.6,  4. ,  6.2,  5.9,  6.5,  5.7,
        6.3,  7.2,  6.6,  7.3,  7.1,  6.9,  3.5,  5. ,  4.5,  6.4,  4.1,
        4.8,  8.1,  5.5,  6.8,  6.1,  7.7,  5.1,  7.6,  3.1,  3.3,  7.8,
        8.4,  5.2,  4.3,  5.8,  4.6,  7.5,  6.7,  3.6,  3.9,  5.4,  4.2,
        5.3,  3.4,  3. ,  8. ,  6. ,  3.8,  7.9,  2.7,  4.9,  2.4,  3.7,
        3.2,  2.5,  2.8,  2.6,  2.9,  8.2,  8.7,  8.3,  9.3,  8.8,  2.1,
        2.3,  8.5,  8.6,  9. ,  9.6,  1.7,  9.1,  2. ,  1.4,  8.9,  1.9,
        9.4,  9.7,  1.8,  9.2,  1.6, 10. ,  2.2,  1.1])
In [63]:
df['Duration'].unique()
Out[63]:
array([ nan, 109.,  90., 110., 105., 147., 142.,  59.,  82., 116.,  96.,
       120., 161., 166., 102.,  87., 132.,  66., 146., 112., 168., 158.,
       126.,  94., 138., 124., 144., 157., 136., 107., 113.,  80., 122.,
       149., 148., 130., 121., 188., 115., 103., 114., 170., 100.,  99.,
       140., 128.,  93., 125., 145.,  75., 111., 134.,  85., 104.,  92.,
       137., 127., 150., 119., 135.,  86.,  76.,  70.,  72., 151.,  95.,
        52.,  89., 143., 177., 117., 123., 154.,  88., 175., 153.,  78.,
       139., 133., 101., 180.,  60.,  46., 164., 162., 171., 160., 152.,
        62., 163., 165., 141., 210., 129., 156., 240., 172., 155., 118.,
       167., 106., 193.,  57., 108.,  45., 195., 174.,  81., 178.,  58.,
       184.,  97.,  98., 131., 176., 169.,  77.,  91.,  84., 173.,  74.,
        67., 181., 300.,  79.,  65.,  48., 183., 159.,  83.,  68.,  49.,
       201.,  64., 186.,  50.,  69., 207.,  55.,  61., 185., 187., 216.,
        63.,  54., 198.,  51.,  71.,  73., 218., 191., 321., 199.,  53.,
        56., 179.,  47., 206., 190., 211., 247., 213., 223.,   2., 189.,
       224., 202., 255., 197., 182., 214., 208.,  21., 200., 192.,  37.,
       261., 238., 204., 235., 298., 217., 250.])
In [64]:
df.groupby(['Genre']).count()
Out[64]:
Name Year Duration Rating Votes Director Actor 1 Actor 2 Actor 3
Genre
Action 1289 1265 262 417 417 1249 1207 1124 1005
Action, Adventure 41 41 17 24 24 41 40 39 39
Action, Adventure, Biography 1 1 1 1 1 1 1 1 1
Action, Adventure, Comedy 42 41 37 40 40 42 42 42 42
Action, Adventure, Crime 19 19 11 16 16 19 19 19 19
... ... ... ... ... ... ... ... ... ...
Thriller, Action 2 2 1 1 1 2 2 2 2
Thriller, Musical, Mystery 1 1 1 1 1 1 1 1 1
Thriller, Mystery 3 3 2 3 3 3 3 3 3
Thriller, Mystery, Family 1 1 1 1 1 1 1 1 1
War 8 5 4 3 3 8 8 7 7

485 rows × 9 columns

In [65]:
df["Director"].value_counts().head(6)
Out[65]:
Jayant Desai       58
Kanti Shah         57
Babubhai Mistry    50
Mahesh Bhatt       48
Master Bhagwan     47
Nanabhai Bhatt     46
Name: Director, dtype: int64
In [66]:
df.isnull().any()
Out[66]:
Name        False
Year         True
Duration     True
Genre        True
Rating       True
Votes        True
Director     True
Actor 1      True
Actor 2      True
Actor 3      True
dtype: bool
In [67]:
#printing Total null Values for the column Year and Genre
print('Null Values in Year Column',df['Year'].isnull().sum())
print('Null Values in Genre Column',df['Genre'].isnull().sum())
Null Values in Year Column 528
Null Values in Genre Column 1877
In [68]:
#Dropping null values
df.dropna(subset=['Year'],inplace=True)
df.dropna(subset=['Genre'],inplace=True)
In [69]:
#Checking Null Values again for confirmation. you can also skip the unnessasary stpes here and in above cell
print('Null Values in Year Column',df['Year'].isnull().sum())
print('Null Values in Genre Column',df['Genre'].isnull().sum())
Null Values in Year Column 0
Null Values in Genre Column 0
In [70]:
#replacing null values with the most common rating given to an Indian Movie
df['Rating'].fillna(df['Rating'].mode().max(),inplace=True)

#replacing null values with average duration of a movie in India
df['Duration'].fillna(df['Duration'].mean(),inplace=True)

#replacing null values with average votes recived by a Movie
df['Votes'].fillna(df['Votes'].mean(),inplace=True)
In [71]:
df.isnull().any()
Out[71]:
Name        False
Year        False
Duration    False
Genre       False
Rating      False
Votes       False
Director     True
Actor 1      True
Actor 2      True
Actor 3      True
dtype: bool
In [72]:
df.duplicated().sum()
Out[72]:
4
In [73]:
def Talents(column):
    global df
    df[column].value_counts().sort_values(ascending=False)[:10].plot(kind="bar", figsize=(20,6), edgecolor="k")
    plt.xticks(rotation=0)
    plt.title("Top Ten {}".format(column))
    plt.xlabel(column)
    plt.ylabel("Count")
    plt.show()
In [74]:
def Histo(column):
    global df
    plt.figure(figsize=(20,6))
    plt.hist(df[column], edgecolor="k")
    plt.xticks(rotation=0)
    plt.title("Histogram of {}".format(column))
    plt.xlabel(column)
    plt.ylabel("Frequency")
    plt.show()
In [75]:
def Scatter(x, y, c=None):
    global df
    plt.figure(figsize=(20,6))
    plt.scatter(df[x], df[y], edgecolor="k", c=c)
    plt.xticks(rotation=0)
    plt.title("Scatter plot X:{} / Y:{}".format(x, y))
    plt.xlabel(x)
    plt.ylabel(y)
    plt.show()   
In [76]:
Talents("Director")
No description has been provided for this image
In [77]:
Talents("Actor 1")
No description has been provided for this image
In [78]:
Talents("Actor 2")
No description has been provided for this image
In [79]:
Talents("Actor 3")
No description has been provided for this image
In [80]:
Histo("Year")
No description has been provided for this image
In [81]:
Histo("Duration")
No description has been provided for this image
In [82]:
Histo("Votes")
No description has been provided for this image
In [83]:
Histo("Rating")
No description has been provided for this image
In [84]:
import matplotlib.pyplot as plt
from itertools import combinations

def plot_histograms(data, col1, col2):
    plt.figure(figsize=(10, 5))
    plt.subplot(1, 2, 1)
    plt.hist(data[col1], bins=20, color='skyblue')
    plt.title(col1)

    plt.subplot(1, 2, 2)
    plt.hist(data[col2], bins=20, color='salmon')
    plt.title(col2)

    plt.tight_layout()
    plt.show()

# Assuming 'data' is your dataset or DataFrame
data = {
    "Duration": [100, 150, 120, 90, 110],
    "Year": [2010, 2011, 2012, 2013, 2014],
    "Rating": [4.5, 3.8, 4.2, 3.9, 4.1],
    "Votes": [500, 600, 450, 700, 550]
}

columns = ["Duration", "Year", "Rating", "Votes"]
comb = combinations(columns, 2)
comb_list = [list(i) for i in comb]

for col in comb_list:
    plot_histograms(data, col[0], col[1])
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [85]:
import seaborn as sns

sns.pairplot(df)
plt.show()
No description has been provided for this image
In [86]:
non_numeric_columns = df.select_dtypes(exclude=['float64', 'int64']).columns
print(non_numeric_columns)
Index(['Name', 'Year', 'Genre', 'Director', 'Actor 1', 'Actor 2', 'Actor 3'], dtype='object')
In [87]:
numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
correlation_matrix = df[numeric_columns].corr(method='spearman')
In [88]:
print(df.columns)
Index(['Name', 'Year', 'Duration', 'Genre', 'Rating', 'Votes', 'Director',
       'Actor 1', 'Actor 2', 'Actor 3'],
      dtype='object')
In [89]:
df.dropna(subset=['Director', 'Actor 1', 'Actor 2', 'Actor 3', 'Genre'], inplace=True)

(round(df.isnull().sum()/df.isnull().count(), 4)*100).sort_values(ascending=False)
Out[89]:
Name        0.0
Year        0.0
Duration    0.0
Genre       0.0
Rating      0.0
Votes       0.0
Director    0.0
Actor 1     0.0
Actor 2     0.0
Actor 3     0.0
dtype: float64
In [90]:
print(df.columns)
Index(['Name', 'Year', 'Duration', 'Genre', 'Rating', 'Votes', 'Director',
       'Actor 1', 'Actor 2', 'Actor 3'],
      dtype='object')

Deploy Models to my code¶

In [91]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score

# Assuming 'df' is your DataFrame

# Extracting the numeric part from the 'Year' column
df['Year'] = df['Year'].str.extract('(\d+)').astype(float)

# Encoding categorical variables based on mean ratings
actor1_encoding_map = df.groupby('Actor 1').agg({'Rating': 'mean'}).to_dict()['Rating']
actor2_encoding_map = df.groupby('Actor 2').agg({'Rating': 'mean'}).to_dict()['Rating']
actor3_encoding_map = df.groupby('Actor 3').agg({'Rating': 'mean'}).to_dict()['Rating']
director_encoding_map = df.groupby('Director').agg({'Rating': 'mean'}).to_dict()['Rating']
genre_encoding_map = df.groupby('Genre').agg({'Rating': 'mean'}).to_dict()['Rating']

df['actor1_encoded'] = round(df['Actor 1'].map(actor1_encoding_map), 1)
df['actor2_encoded'] = round(df['Actor 2'].map(actor2_encoding_map), 1)
df['actor3_encoded'] = round(df['Actor 3'].map(actor3_encoding_map), 1)
df['director_encoded'] = round(df['Director'].map(director_encoding_map), 1)
df['genre_encoded'] = round(df['Genre'].map(genre_encoding_map), 1)

# Drop original categorical columns
df.drop(['Actor 1', 'Actor 2', 'Actor 3', 'Director', 'Genre'], axis=1, inplace=True)

# Define features and target variable
X = df[['Year', 'Duration', 'Votes', 'actor1_encoded', 'actor2_encoded', 'actor3_encoded', 'director_encoded', 'genre_encoded']]
y = df['Rating']

# Split data into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Model Building - Linear Regression
lr = LinearRegression()
lr.fit(X_train, y_train)
lr_pred = lr.predict(X_test)

# Model Building - Random Forest Regressor
rf = RandomForestRegressor()
rf.fit(X_train, y_train)
rf_pred = rf.predict(X_test)

# Evaluate Linear Regression
print('Linear Regression Metrics:')
print('Mean Squared Error:', mean_squared_error(y_test, lr_pred))
print('Mean Absolute Error:', mean_absolute_error(y_test, lr_pred))
print('R2 Score:', r2_score(y_test, lr_pred))

# Evaluate Random Forest Regressor
print('\nRandom Forest Regressor Metrics:')
print('Mean Squared Error:', mean_squared_error(y_test, rf_pred))
print('Mean Absolute Error:', mean_absolute_error(y_test, rf_pred))
print('R2 Score:', r2_score(y_test, rf_pred))
Linear Regression Metrics:
Mean Squared Error: 0.3666260447833504
Mean Absolute Error: 0.4299825006345652
R2 Score: 0.7225086563365914

Random Forest Regressor Metrics:
Mean Squared Error: 0.2627192024346257
Mean Absolute Error: 0.3010049594229074
R2 Score: 0.8011535036119888
In [92]:
import matplotlib.pyplot as plt

# Scatter plot for Linear Regression predictions
plt.figure(figsize=(8, 6))
plt.scatter(y_test, lr_pred, alpha=0.5)
plt.title('Linear Regression: Actual vs Predicted Ratings')
plt.xlabel('Actual Ratings')
plt.ylabel('Predicted Ratings')
plt.show()

# Scatter plot for Random Forest Regressor predictions
plt.figure(figsize=(8, 6))
plt.scatter(y_test, rf_pred, alpha=0.5)
plt.title('Random Forest Regressor: Actual vs Predicted Ratings')
plt.xlabel('Actual Ratings')
plt.ylabel('Predicted Ratings')
plt.show()
No description has been provided for this image
No description has been provided for this image
In [ ]: