# 電影類型隨時(shí)間的變化趨勢(shì)圖fig = plt.figure(figsize=(10, 8)) # 設(shè)置畫圖框尺寸ax1 = plt.subplot(1, 1, 1)# 設(shè)置圖的位置plt.plot(genre_year60) #畫折線圖# 設(shè)置圖形格式plt.title('電影類型隨時(shí)間的變化趨勢(shì)圖', fontsize=18)plt.xlabel('年份', fontsize=18)plt.ylabel('數(shù)量', fontsize=18)plt.xticks(range(1960, 2017, 10))# 設(shè)置x軸的刻度plt.legend(genre_year60)plt.show()fig.savefig('film genre by year.png', dpi=600)
[/code]在研究分類型推薦電影時(shí),為了降低主觀性先刪除評(píng)價(jià)人數(shù)小于100的電影記錄。```codegenres_df['id'] = merge_df['id']genres_df['title'] = merge_df['title']genres_df['vote_average'] = merge_df['vote_average']genres_df['vote_count'] = merge_df['vote_count']# 刪除評(píng)價(jià)人數(shù)小于100的電影genres_df = genres_df[genres_df['vote_count'] > 100]
[/code]例如針對(duì)劇情Drama電影,在genres_df中找出'Drama'值為1的記錄,新建數(shù)據(jù)框,加入電影的id, title, vote_average,
tagline, overview,利用vote_average降序排列,取前20個(gè)記錄。drama類型下,評(píng)分前20的電影如下圖,同理其他類型。drama類型下的推薦電影:### ###
3.2 問題2. 按制作國家分類推薦也許就是一時(shí)興起就想看一個(gè)美國大片,或者看個(gè)迪士尼的動(dòng)漫也還挺好,哎看個(gè)日本的文藝小清新片子也是個(gè)不錯(cuò)的idea。首先看哪種國家電影數(shù)量最多,及每個(gè)國家的電影隨時(shí)間的變化趨勢(shì)。由于很多電影的制作國家不止一個(gè),所以按問題一中的思路,提取所有的電影制作國家,對(duì)各個(gè)國家進(jìn)行one-
hot編碼,如果一個(gè)值中包含指定內(nèi)容,則編碼為1,否則編碼為0。考查哪種國家電影數(shù)量最多,用pie圖看每個(gè)國家電影數(shù)目比例。每個(gè)國家的電影隨時(shí)間的變化趨勢(shì)。以美國為例,按制作國家推薦電影。美國電影評(píng)分top20:id | title | vote_average | tagline
---|---|---|---
278 | The Shawshank Redemption | 8.5 | Fear can hold you prisoner. Hope
can set you f...
238 | The Godfather | 8.4 | An offer you can't refuse.
550 | Fight Club | 8.3 | Mischief. Mayhem. Soap.
240 | The Godfather: Part II | 8.3 | I don't feel I have to wipe
everybody out, Tom...
424 | Schindler's List | 8.3 | Whoever saves one life, saves the world
entire.
244786 | Whiplash | 8.3 | The road to greatness can take you to the
edge.
680 | Pulp Fiction | 8.3 | Just because you are a character doesn't mean
...
510 | One Flew Over the Cuckoo's Nest | 8.2 | If he's crazy, what does
that make you?
497 | The Green Mile | 8.2 | Miracles do happen.
769 | GoodFellas | 8.2 | Three Decades of Life in the Mafia.
73 | American History X | 8.2 | Some Legacies Must End.
13 | Forrest Gump | 8.2 | The world will never be the same, once you've
...
311 | Once Upon a Time in America | 8.2 | Crime, passion and lust for
power - Sergio Leo...
1891 | The Empire Strikes Back | 8.2 | The Adventure Continues...
539 | Psycho | 8.2 | The master of suspense moves his cameras into ...
155 | The Dark Knight | 8.2 | Why So Serious?
389 | 12 Angry Men | 8.2 | Life is in their hands. Death is on their
minds.
27205 | Inception | 8.1 | Your mind is the scene of the crime.
11 | Star Wars | 8.1 | A long time ago in a galaxy far, far away...
77 | Memento | 8.1 | Some memories are best forgotten. ### 3.3 問題3. 按熱門電影推薦根據(jù)popularity的值從高到低排序。輸出結(jié)果如下,可見按popularity推薦的是比較新的人們關(guān)注度高的電影,例如小黃人,星際穿越,死侍,銀河護(hù)衛(wèi)隊(duì)等等。id | title | year | polularity
---|---|---|---
211672 | Minions | 2015 | 875.581305
157336 | Interstellar | 2014 | 724.247784
293660 | Deadpool | 2016 | 514.569956
118340 | Guardians of the Galaxy | 2014 | 481.098624
76341 | Mad Max: Fury Road | 2015 | 434.278564
135397 | Jurassic World | 2015 | 418.708552
22 | Pirates of the Caribbean: The Curse of the Bla... | 2003 |
271.972889
119450 | Dawn of the Planet of the Apes | 2014 | 243.791743
131631 | The Hunger Games: Mockingjay - Part 1 | 2014 | 206.227151
177572 | Big Hero 6 | 2014 | 203.734590
87101 | Terminator Genisys | 2015 | 202.042635
271110 | Captain America: Civil War | 2016 | 198.372395
244786 | Whiplash | 2014 | 192.528841
155 | The Dark Knight | 2008 | 187.322927
286217 | The Martian | 2015 | 167.932870
27205 | Inception | 2010 | 167.583710
109445 | Frozen | 2013 | 165.125366
209112 | Batman v Superman: Dawn of Justice | 2016 | 155.790452
19995 | Avatar | 2009 | 150.437577
550 | Fight Club | 1999 | 146.757391 ### 3.4 問題4. 按評(píng)分推薦分?jǐn)?shù)要較高且評(píng)分人數(shù)高于某值,取評(píng)分人數(shù)大于100的記錄,顯示前20個(gè)。輸出結(jié)果如下,可見按評(píng)分推薦的是一些比較經(jīng)典的,像肖申克的救贖,教父,辛德勒的名單等等。id | title | year | vote_average
---|---|---|---
278 | The Shawshank Redemption | 1994 | 8.5
238 | The Godfather | 1972 | 8.4
424 | Schindler's List | 1993 | 8.3
680 | Pulp Fiction | 1994 | 8.3
129 | Spirited Away | 2001 | 8.3
240 | The Godfather: Part II | 1974 | 8.3
244786 | Whiplash | 2014 | 8.3
550 | Fight Club | 1999 | 8.3
510 | One Flew Over the Cuckoo's Nest | 1975 | 8.2
13 | Forrest Gump | 1994 | 8.2
155 | The Dark Knight | 2008 | 8.2
389 | 12 Angry Men | 1957 | 8.2
128 | Princess Mononoke | 1997 | 8.2
497 | The Green Mile | 1999 | 8.2
539 | Psycho | 1960 | 8.2
346 | Seven Samurai | 1954 | 8.2
1891 | The Empire Strikes Back | 1980 | 8.2
73 | American History X | 1998 | 8.2
4935 | Howl's Moving Castle | 2004 | 8.2
769 | GoodFellas | 1990 | 8.2 與問題二的結(jié)果對(duì)比,可見美國評(píng)分top20里面包括了大部分總體電影評(píng)分top20,也正好證實(shí)了美國是電影大國,有質(zhì)有量。### 3.5 問題5. 按觀影者心情推薦抑郁的人推薦小眾文藝片,從生活出發(fā)到靈魂結(jié)束,在平淡中找到人生的意義,積極向上的電影;無聊的人推薦喜劇,科技探索片也是個(gè)不錯(cuò)的選擇;開心的人推薦燒腦片之類的劇情電影,讓你忘掉開心,【笑臉】。觀影者心情與電影類型對(duì)應(yīng)表 觀影者心情 | 對(duì)應(yīng)推薦的電影類型
---|---
高興happy | Drama, adventure, thriller, horror
傷心sad | Comedy, science fiction, family, fantasy
迷茫exhausted | Romance, adventure, family, mystery
無聊bored | Comedy, science fiction, thriller, crime
輕松relaxed | Drama, comedy, romance,music
孤獨(dú)lonely | comedy, family, mystery, documentary
生氣angry | Comedy, adventure, family, crime 以傷心sad為例,推薦這四種Comedy, science fiction, family, fantasy電影的前10個(gè)。###有個(gè)問題暫時(shí)不知道怎么解決,就是怎么同時(shí)找出每個(gè)類型的評(píng)分前20,由于每部電影屬于多個(gè)類型,這樣就會(huì)有重復(fù)的記錄,在類型少的時(shí)候可以一個(gè)一個(gè)找出但是太多的時(shí)候就不行了,如果有人看的話希望可以多多交流多多學(xué)習(xí)。[1] Kaggle——TMDB 5000 Movie Dataset電影數(shù)據(jù)分析. [
https://blog.csdn.net/zhuoyue65/article/details/80285875
](https://blog.csdn.net/zhuoyue65/article/details/80285875)