NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > R > Networks of Film Makers

Networks of Film Makers

Christopher Redino
Posted on Mar 7, 2016

Contributed by Christopher Redino. He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between January 11th to April 1st, 2016. This post is based on his first class project - R visualization (due on the 2th week of the program).

Motivation

We often hear that in many fields success isnโ€™t based on what you know, but who you know. This is perhaps especially true in the film industry, and for young actors and film makers trying to catch a big break, the right connection can make all the difference. Itโ€™s easy enough to look up who has collaborated with whom for films on websites like IMDB, Box Office Mojo, or even just Wikipedia, but to visualize the larger network of film makers requires a little more work. Such a visualization (if it is effective) may lead to some insights into larger patterns that can inform the career decisions for aspiring film makers. One way to think of this visualization map is that it can show us how separated actors are through their collaborations. If youโ€™ve ever played the game โ€œsix degrees of Kevin Baconโ€ then you may have some expectation about how dense and throughly connected this network map will be.

The Data

A first exploratory attempt at this visualization is made here with data that has been scraped from boxofficemojo.com. The scraper itself isnโ€™t the focus of this project, but the entire source code and sample output can be found  here.

The data as scraped has one row for each movie listed on Box Office Mojo and various information about each movie. The first five rows are shown here as an example.

the_data

Even in just these five examples we can see the records from Box Office Mojo are very incomplete, and this will affect the accuracy/utility of the network map, but the silver lining is that the same scraper and code below can be applied later as the records are updated over time. The incompleteness of the original data (and the sub-setting of the data we will do later) may make it appear as if some rather famous actors have very few collaborators. At this time, for the quality of the data, it is not very useful for looking at individuals, but hopefully we can learn something about the larger features of the network as whole, or large subsets, such as all actors associated with a certain studio.

The data we are interested in is which actors/directors/writers etc appear with each other, and looking at the collection of all movies it seems like we already have all the information we need, but there are actually quite a few steps before we can make a network map. The first step is to decide what kinds of visualizations we intend to make, and choose the package(s) that will let us do this efficiently. There are many ways to represent a network visually, but for this first look we will use a basic network map, (and one slight variation). To do this we will actually try two separate packages, igraph and networkD3, each with their own advantages/disadvantages.

lib1

Both of these packages however are expecting the input data in a certain format. In particular, they expect a data frame listing all the โ€œnodesโ€ and a data frame listing all the โ€œlinksโ€. The nodes of the network in this case are the actors and other film makers, and the node data frame will also contain any properties of the nodes we want to use to group or filter them by. The links of the network are the connections among the nodes, every incidence of one actor/film makers appearing with another is one โ€œlinkโ€. The link data frame contains all these connections as well as any properties of the links themselves we may want to highlight in our visualization.

Most of the work that needs to be done to get to our visualizations is the reshaping, and while the highlights will be shown to follow along conceptually, there are commissions here. To reshape the data from a data frame of movies into the node and link data frames there are two more libraries that are very useful, dyplr and reshape2.

lib2

The Node Data Frame

The node frame is the easier of the two to make. Starting from the data frame with all the info for each movie, we only select out the listings of people that contributed to the film, the actors/directors/writers etc that we want to include in our map. For simplicity going forward we are only going to consider the actors with the top 6 billing spots in each movie (or less if less are listed), but the rest of the code is general enough that we can simply add back in those other people, such as writers and directors, if we so wanted with very few alterations in what follows.

code1

We then โ€œmeltโ€ this data frame to get one big list of people.

code2

Besides some other steps in cleaning and indexing properly (not shown) this one melt step is most of the work for the node data frame. But with just a list of nodes our network plot may be a little boring, so we want to also add characteristics to each node, so that we may filter or group actors based on their attributes. This step involves a little more work. The characteristics we are going to consider here are the preferred genre and studio for each actor as well as their average budget and domestic box office returns on the movies they appear in. The โ€œpreferredโ€ genre/studio here are considered to be the one that the actor/actress appears in most frequently and if there is a tie will consider the preference to be โ€œnoneโ€. Looking at the data frame of movies we see this isnโ€™t information that is already given to us, but it is information we can get by doing a bit more reshaping.

Node Attributes

The first step to including these characteristics is to get all the data from the original movies data frame that contributes to them.

code3

This new frame of attributes will require a few cleaning steps also (not shown). But then once we have it we can use it to calculate a new column of attributes which can then be glued onto our node data frame. As an example, the method used for getting the preferred genre is shown (including some cleaning steps), but the other characteristics are computed in a similar way.

code4

Sub-setting Our Nodes

Before going on to make the link data frame, this is the right time to reduce our list of nodes if we so chose. As we will see, doing a network plot for many nodes with a very large number of links can produce a network map that is less than useful, and taking a subset based on attributes can make the results more interpretable. Now that the node data frame has attributes we can simply filter based on those attributes to get the subsets we want. The filters shown here are just one example, and at this step we have a lot of options.

code5

We now have the node data frame completed, and we can take a look at it to review what we have done so far.

code6

The Link Data Frame

Finally we are ready to make the other main data frame we need, the link frame. Unfortunately the structure of this frame (one row for each connection among actors) requires reshaping which is a little more complicated.

Aside from a little setup which is not shown, the main reshaping can be performed by one main function which we apply to the film maker data frame (the filtered version of the movie data frame we made early on).

code7

This function steps through all rows (movies) of the film makers data frame (simultaneously), and finds all connections of the first actor listed by stepping through and recording every other actor. It then steps to the 2nd actor listed and finds all of their connections in the same way (without counting those weโ€™ve already recorded for this movie.) While there are nested for loops here for stepping through actors, it is important that the outer most layer, the part that steps through movies is NOT done as a for loop and is instead done in a way that is vectorized (simultaneous). This is because depending on how we subset our nodes we could have many thousands of movies to step through and this could cause considerable slow down if the nested for loop had to be performed thousands of times sequentially.

There are a few more steps needed to make the link data frame work properly, but this function and its application are the most important part. Before moving forward letโ€™s see what the link data frame looks like, just so we have a better idea of whats going on.

code8

The source and target columns give the id numbers that correspond to the actors in the node data frame, the โ€œweightโ€ here shows how many times actors have collaborated with one another, and the link_genre indicates if the link is between actors with a common genre preference (this will be useful in a moment).

Results

For the filters applied above weโ€™ve reduce the total number of actors to be considered but we still have hundreds of actors and thousands of connections. For our first network map we will simply try to show how all of these hundreds of actors are connected, using the networkD3 package.

plot1

This is an example of a โ€œforce networkโ€ which is actually like a small physics simulation which tries to settle into a stable configuration to display the nodes and their links in a neat and clean matter. โ€œNeat and cleanโ€ may be a bit of an overstatement however, as even with our filters, the hundreds of actors show so many connections that it is a bit of mess and hard to extract useful information from.

With the attributes weโ€™ve defined for the actors we could do further filtering, and perhaps glean more information if we looked only at one studio or one genre perhaps, but instead lets try to learn something about this rather large population using the group information already encoded here. We will do the same plot again, but this time the nodes (actors) will be colored by their dominate genre.plot2

 

Surprisingly (at least to me, as an outsider to the film industry) we see the network split into two main hemispheres, the dominate two colors in the two hemispheres correspond to actors that favor comedy and that favor drama, with other genres like action in their own little domains, like countries with borders on a globe. There are also some genres whose actors do not stick to one territory, like the nomadic horror or romance actors/actresses.

We may still think this is an overly messy way of representing a network of this size and level of connectivity, but there are many other options for how we visualize this network. One other way which will be shown here is a a network map that instead of using โ€œforcesโ€ to find a stable configuration, we simple force the nodes into a ring, and organize those nodes by genre. Furthermore, we can color the links between nodes if the actors sharing that link both have the same preferred genre. We will accomplish this with the igraph package. While the igraph network plots are not animated, and require us to specify a lot more parameters, they do allow for a bit more customization, which may be helpful when we are not sure at first how exactly we want to visualize a network.

code9

After defining our layout, and our coloring scheme we can do the plot.

plot3

While there is a little over plotting here (gray lines with no genre being drawn over the colored lines), we can still see the same effect we noticed on the previous plot, that drama actors usually work with other drama actors, and comedy actors usually work with other comedy actors, while other genres donโ€™t have as strong a preference.

This is just one example of the type of visualization we can make with this code, as we can change our filters and our visualization options now that we have set up the data frames correctly. With the full code we can explore more relationships within these film maker networks, like investigating to what degree different studioโ€™s actors tend to stick to themselves, or how often actors with a history of large box office success collaborate with actors that prefer a lower budget. Furthermore, if the data becomes more complete with time (which hopefully Box Office Mojo is working on), once we see these trends and their expectations we can single out which individuals are constituting these relationships, perhaps giving a young film maker some insight into how they themselves want to try and be a part of that network.

You do often hear that itโ€™s not what you know, itโ€™s who you know, but with the right data and the right analysis you donโ€™t have to make that choice between the two.

About Author

Christopher Redino

The common thread through all of Christopher's endeavors is his love of problem solving, with his usual methods being analytical and computational in nature. Having learned coding at an early age, Christopher picks up new programming languages quickly...
View all posts by Christopher Redino >

Leave a Comment

Cancel reply

You must be logged in to post a comment.

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application