Bollywood Movie Mania in MATLAB

Bollywood Movie Mania in MATLAB

Hello LinkedIn Friends & Followers.

It’s been a long period since my last post, and I am sorry for the delay. You always want to get things done on time, but some stuff happens, and you keep on delaying things that are not monitored or can be delayed without much repercussion. Ok, I never expected to get several comments on my articles, but I thought a few comments should have been there. But really, none? With each new article, I get hundreds of new subscribers to my?GG’s Journal, and thanks to you, my existing subscribers, and readers, I feel I am doing something important, and I want to keep doing it. I will also try to make up the lost articles of the previous month with helpful content for you. Apart from NOT writing these LinkedIn Articles, I was still gathering new insights day and night, and I have tons of ideas to be implemented. I would also request you to comment with your thoughts on this article or anything you suggest I should write next!

One of my colleagues has been working on Plotting different film genres' popularity in MATLAB. He wanted to do it with the Hollywood database, but he could not find a suitable database until the last few days. During this period, I found a nice dataset for Bollywood movies from?Adrian McMahon?on data.world. My colleague still wanted to do with Hollywood movies considering it would be a considerable number and more liked by college students and peers. Now that he has got that dataset and is not working with the Bollywood movies, I am taking this as an opportunity to work something more with the database I found. In this article, I will show you some incredible capabilities of MATLAB with examples that would make sense to even non-programmers!

First, how do you load the dataset in MATLAB? You can download the Excel file from the Author’s Page, put it in the folder where your current MATLAB directory is, and use the following command:

data = readtable('IMDb Movies India.csv');        

We will have a variable containing 15509 rows of Name, Year, Duration, Genre, Rating, Values, Votes, Director, Actor1, Actor2, and Actor3.

No alt text provided for this image

Now we will do some operations and get desired results. We will start by knowing how many movies are released each year. I will not explain or discuss MATLAB Code in this article, but if you have any queries, please post them in the comments!

%% Movies released every year in Bollywood
newData = rmmissing(data,'DataVariables',{'Year'});
years = str2num(cell2mat(newData.Year(:)));
years = categorical(years);
tbl = tabulate(years);
t = cell2table(tbl,'VariableNames', ...
? ? {'Year','Count','Percent'});
t.Year = categorical(t.Year);
figure; bar(t.Year,t.Count); set(gcf, 'Position', get(0, 'Screensize'));
xlabel('Year'); ylabel('Number of Movies released')        
No alt text provided for this image

You must have also played the Movie Antakshari Game. Well, I have played a lot in my school and college days. After some regular guesses, we get stuck and do not recall movie names. We started googling so that we could win the game. But guess what, if you use this existing Excel File, you will already have a list of Bollywood Movies in alphabetical order. Do you want a movie name to show randomly based on the alphabet you mention? Let’s use this code:

%% Movies Antakshari Game
newData = rmmissing(data,'DataVariables',{'Name'});
movie = char(newData.Name);
firstChar = lower(movie(:,1));
fc = categorical(string(firstChar));
inp = lower(input('Enter first alphabet for movie name:','s'));
idx? = find(fc == inp);
fprintf('There are %d movies starting from alphabet %s\n',length(idx),inp)
randomIndex = randi(length(idx));
randomMovie = newData.Name(idx(randomIndex));
fprintf('Randomly Guessed Bollywood Movie from %s: %s\n',inp,string(randomMovie));        

Here’s a trial of the game:

Enter first alphabet for movie name:Q
There are 52 movies starting from alphabet q
Randomly Guessed Bollywood Movie from q: Qurbaniyaan

Did you love it? Now, let us try one more give before I give you some tasks of your own to take this article forward. We will find the number of movies across different ranges of movie duration and see the movie duration for the maximum number of films. Here is the code:

%% Movie Duration
newData = rmmissing(data,'DataVariables',{'Duration'});
duration = replace(string(newData.Duration),' min'," ");
duration = str2double(duration);
figure; histogram(duration)        
No alt text provided for this image

After removing missing data entries, you will notice that we were only left with 7240 movies across the database. Maximum 683 movies were in the range of 135 to 140 minutes. The surprising thing was 29 movies were longer than 4 hours. Who would survive watching such long movies? Have you seen any Bollywood Movies for more than 4 hours?

We can do several more things with this database. One of them is finding the genre’s popularity across years, which you can expect as a YouTube #Shorts video with a Hollywood database in the coming few days. Now, let me give you some Homework or Task, whatever you consider:

  1. Find the number of movies done by any Actor in their entire career?
  2. Find an actor who has done a primarily supporting role, i.e., Actor2 in the database?
  3. Which director has the highest rating in a movie in the Comedy genre?

I am looking forward to you solving the above problems. If you can do them, share your codes in the comments, or post your error or problem in the comments even if you get stuck at any stage. Let's enjoy MATLAB while doing some fun stuff. Happy MATLABing!

要查看或添加评论,请登录

Gunjan Gupta的更多文章

  • Decoding G20 Summit 2023: What a MATLAB WordCloud Reveals

    Decoding G20 Summit 2023: What a MATLAB WordCloud Reveals

    The G20 India Summit 2023 in New Delhi has been the talk of the town, especially with India playing the host and PM…

    1 条评论
  • How do Small Saving Schemes compare to Inflation?

    How do Small Saving Schemes compare to Inflation?

    On March 31, 2022, Govt of India announced the Interest Rate for various Small Saving Schemes like PPF, NSC, SCSS…

  • Analyze Tax Saving Investment under 80C with MATLAB

    Analyze Tax Saving Investment under 80C with MATLAB

    Hey. This is the time of the year when all Tax Payers who have not done anything during the entire year start thinking…

  • Evaluate Cryptocurrency Craze in MATLAB

    Evaluate Cryptocurrency Craze in MATLAB

    Hi. Last week, I created a poll inquiring about the next live interactive session topic.

    2 条评论
  • Equation Instruction Rotation Simulation & Population

    Equation Instruction Rotation Simulation & Population

    Hi Reader! Give a big shout to yourself for subscribing to GG's Journal. I hope you have read my previous two articles:…

  • From #shorts to long work, Kanban is the way to go!

    From #shorts to long work, Kanban is the way to go!

    Hi Reader! Thanks for giving your valuable time to come and read this new article under GG's Journal. I am thrilled to…

  • How to make #shorts with MATLAB?

    How to make #shorts with MATLAB?

    Hi folks! Thank you for reading my article, and I hope you join my newsletter: GG's Journal. This is my second article…

  • Life is a Hackathon. How to solve it?

    Life is a Hackathon. How to solve it?

    Greetings Everyone! Wishing you a Happy New Year! Is it too late to wish now? Maybe, but doing it seems better than…

    2 条评论
  • 5 - Webinar Series @ MATLAB Helper

    5 - Webinar Series @ MATLAB Helper

    Hello friend. For the last few weeks, we have been conducting several webinars as well as the live interactive sessions…

    5 条评论
  • Arduino with MATLAB - Webinar #3

    Arduino with MATLAB - Webinar #3

    After Conducting two successful webinars on Arduino, MATLAB Helper in association with Airavath Foundation is…

社区洞察

其他会员也浏览了