In October 2015, Walt Hickey from FiveThirtyEight published a popular article where he presented strong evidence which suggest that Fandango's movie rating system was biased and dishonest.

In this project, we'll analyze more recent movie ratings data to determine whether there has been any change in Fandango's rating system after Hickey's analysis.

In [1]:

```
import pandas as pd
previous = pd.read_csv('fandango_score_comparison.csv')
after = pd.read_csv('movie_ratings_16_17.csv')
previous.head()
```

Out[1]:

In [2]:

```
after.head()
```

Out[2]:

In [3]:

```
fandango_previous = previous[['FILM', 'Fandango_Stars',
'Fandango_Ratingvalue',
'Fandango_votes',
'Fandango_Difference']].copy()
fandango_after = after[['movie', 'year', 'fandango']].copy()
fandango_previous.head()
```

Out[3]:

In [4]:

```
fandango_after.head()
```

Out[4]:

Our goal is to determine whether there has been any change in Fandango's rating system after Hickey's analysis. The population of interest for our analysis is made of all the movie ratings stored on Fandango's website, regardless of the releasing year.

Because we want to find out whether the parameters of this population changed after Hickey's analysis, we're interested in sampling the population at two different periods in time — previous and after Hickey's analysis — so we can compare the two states.

The data we're working with was sampled at the moments we want: one sample was taken previous to the analysis, and the other after the analysis. We want to describe the population, so we need to make sure that the samples are representative, otherwise we should expect a large sampling error and, ultimately, wrong conclusions.

**Sample Before**

From Hickey's article and from the README.md of the data set's repository, we can see that he used the following sampling criteria:

- The movie must have had at least 30 fan ratings on Fandango's website at the time of sampling (Aug. 24, 2015).
- The movie must have had tickets on sale in 2015.

The sampling was clearly not random because not every movie had the same chance to be included in the sample — some movies didn't have a chance at all (like those having under 30 fan ratings or those without tickets on sale in 2015). It's questionable whether this sample is representative of the entire population we're interested to describe. It seems more likely that it isn't, mostly because this sample is subject to temporal trends — e.g. movies in 2015 might have been outstandingly good or bad compared to other years.

**Sample After**

The sampling conditions for our other sample were (as it can be read in the README.md of the data set's repository):

- The movie must have been released in 2016 or later.
- The movie must have had a considerable number of votes and reviews (unclear how many from the README.md or from the data).

This second sample is also subject to temporal trends and it's unlikely to be representative of our population of interest.

**Purposive Sampling**

Both these authors had certain research questions in mind when they sampled the data, and they used a set of criteria to get a sample that would fit their questions. Their sampling method is called purposive sampling (or judgmental/selective/subjective sampling). While these samples were good enough for their research, they don't seem too useful for us.

At this point, we can either collect new data or change our the goal of our analysis. We choose the latter and place some limitations on our initial goal.

Instead of trying to determine whether there has been any change in Fandango's rating system after Hickey's analysis, our new goal is to determine whether there's any difference between Fandango's ratings for popular movies in 2015 and Fandango's ratings for popular movies in 2016. This new goal should also be a fairly good proxy for our initial goal.

With this new research goal, we have two populations of interest:

- All Fandango's ratings for popular movies released in 2015.
- All Fandango's ratings for popular movies released in 2016.

**Checking whether movies are popular in both populations**

We need to be clear about what counts as popular movies. We'll use Hickey's benchmark of 30 fan ratings and count a movie as popular only if it has 30 fan ratings or more on Fandango's website.

Although one of the sampling criteria in our second sample is movie popularity, the sample doesn't provide information about the number of fan ratings. We should be skeptical once more and ask whether this sample is truly representative and contains popular movies (movies with over 30 fan ratings).

One quick way to check the representativity of this sample is to sample randomly 10 movies from it and then check the number of fan ratings ourselves on Fandango's website. Ideally, at least 8 out of the 10 movies have 30 fan ratings or more.

In [5]:

```
fandango_after.sample(10, random_state=1)
```

Out[5]:

Above we used a value of 1 as the random seed. This is good practice because it suggests that we weren't trying out various random seeds just to get a favorable sample.

As of January 2019, these are the fan ratings we found:

Movie |
Fan Ratings |
---|---|

Mechanic: Resurrection | 2250 |

Warcraft | 7280 |

Max Steel | 494 |

Me Before You | 5270 |

Fantastic Beasts and Where to Find Them | 13477 |

Cell | 18 |

Genius | 127 |

Sully | 11889 |

A Hologram for the King | 501 |

Captain America: Civil War | 35143 |

90% of the movies in our sample are popular. This is enough and we move forward with a bit more confidence.

Let's also double-check the other data set for popular movies. The documentation states clearly that there're only movies with at least 30 fan ratings, but it should take only a couple of seconds to double-check here.

In [6]:

```
len(fandango_previous[fandango_previous['Fandango_votes'] < 30])
```

Out[6]:

**Isolating movies released in 2015 from our fandango_previous data set**

In [7]:

```
fandango_previous.head()
```

Out[7]:

In [8]:

```
fandango_previous['Year'] = fandango_previous['FILM'].str[-5:-1]
fandango_previous.head()
```

Out[8]:

In [9]:

```
fandango_previous['Year'].value_counts()
```

Out[9]:

In [10]:

```
# Creating a seperate data set
fandango_2015 = fandango_previous[fandango_previous['Year']
== '2015'].copy()
fandango_2015['Year'].value_counts()
```

Out[10]:

**Isolating movies released in 2016 from our fandango_after data set**

In [11]:

```
fandango_after.head()
```

Out[11]:

In [12]:

```
fandango_after['year'].value_counts()
```

Out[12]:

In [13]:

```
# Creating a seperate data set
fandango_2016 = fandango_after[fandango_after['year'] == 2016].copy()
fandango_2016['year'].value_counts()
```

Out[13]:

In [57]:

```
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib.style as style
style.use('fivethirtyeight')
from numpy import arange
font = {'family': 'serif',
'color': 'black',
'weight': 'bold',
'size': 14,
}
fandango_2015['Fandango_Stars'].plot.kde(label='2015', figsize=(10, 7.8), color = '#FFB7A2')
fandango_2016['fandango'].plot.kde(label='2016', color='#96BBE6')
plt.title("Comparing distribution shapes for Fandango's ratings\n(2015 vs 2016)", y = 1.0)
plt.xlim(0, 5)
plt.xlabel('Stars')
plt.xticks(arange(0, 5.1, 0.5))
plt.legend(loc='upper left', fontsize=14)
plt.savefig('density.png')
plt.show()
```

The striking aspect of the figure above is:

- The 2016 distribution is slightly shifted to the left relative to the 2015 distribution.

The slight left shift of the 2016 distribution is very interesting for our analysis. It shows that ratings were slightly lower in 2016 compared to 2015. This suggests that there was a difference indeed between Fandango's ratings for popular movies in 2015 and Fandango's ratings for popular movies in 2016. We can also see the direction of the difference: the ratings in 2016 were slightly lower compared to 2015.

In [15]:

```
fandango_2015['Fandango_Stars'].value_counts(normalize=True).sort_index() * 100
```

Out[15]:

In [16]:

```
fandango_2016['fandango'].value_counts(normalize=True).sort_index() * 100
```

Out[16]:

In 2016, very high ratings (4.5 and 5 stars) had significantly lower percentages compared to 2015. In 2016, under 1% of the movies had a perfect rating of 5 stars, compared to 2015 when the percentage was close to 7%. Ratings of 4.5 were also more popular in 2015 — there were approximately 13% more movies rated with a 4.5 in 2015 compared to 2016.

The minimum rating is also lower in 2016 — 2.5 instead of 3 stars, the minimum of 2015. There clearly is a difference between the two frequency distributions.

For some other ratings, the percentage went up in 2016. There was a greater percentage of movies in 2016 that received 3.5 and 4 stars, compared to 2015. 3.5 and 4.0 are high ratings and this challenges the direction of the change we saw on the kernel density plots.

In [17]:

```
def get_stats(data, col):
return list([data[col].mean(), data[col].median(),
data[col].mode()[0]])
print('Fandango 2015')
print(get_stats(fandango_2015, 'Fandango_Stars'), '\n')
print('Fandango 2016')
print(get_stats(fandango_2016, 'fandango'))
summary = pd.DataFrame(index=['Mean', 'Median', 'Mode'])
summary['2015'] = get_stats(fandango_2015, 'Fandango_Stars')
summary['2016'] = get_stats(fandango_2016, 'fandango')
summary
```

Out[17]:

In [27]:

```
summary['2015'].plot.bar(color = '#FFB7A2', align = 'center', label = '2015', width = .25)
summary['2016'].plot.bar(color = '#96BBE6', align = 'edge', label = '2016', width = .25,
rot = 0, figsize = (8,5))
plt.title('Comparing summary statistics: 2015 vs 2016', y=1.07)
plt.ylim(0,5.5)
plt.yticks(arange(0,5.1,.5))
plt.ylabel('Stars')
plt.legend(loc = 'upper center')
plt.savefig('summary.png')
plt.show()
```

In [19]:

```
(summary.loc['Mean'][0] - summary.loc['Mean'][1]) / summary.loc['Mean'][0]
```

Out[19]:

The mean rating was lower in 2016 with approximately 0.2. This means a drop of almost 5% relative to the mean rating in 2015.

Our analysis showed that there's indeed a slight difference between Fandango's ratings for popular movies in 2015 and Fandango's ratings for popular movies in 2016. We also determined that, on average, popular movies released in 2016 were rated lower on Fandango than popular movies released in 2015.

We cannot be completely sure what caused the change, but the chances are very high that it was caused by Fandango fixing the biased rating system after Hickey's analysis.

In [ ]:

```
```