Alright, let's first load the dataset and understand its structure before we dive into the analysis. This will help us determine the type of insights we can derive from the data and choose the most appropriate and creative visualizations to represent those insights. Let's start by loading the Excel file.
The dataset contains information about product recalls by the FDA. Here are the columns and what I understand from them:
FEI Number: A unique identifier for the firm recalling a product.
Recalling Firm Name: The name of the firm recalling a product.
Product Type: The type of product being recalled, such as food/cosmetics or biologics.
Product Classification: The classification of the product, e.g. Class I or Class II.
Status: The status of the recall, whether it's ongoing or has been terminated.
Distribution Pattern: Information about where the product was distributed.
Recalling ,Recalling Firm State,Recalling Firm Country: The location of the recalling firm.
Center Classification Date: The date when the recall was classified.
Reason for Recall: The reason why the product was recalled.
Product Description: A description of the product.
Event ID: A unique identifier for the recall event.
Event Classification: The classification of the recall event.
Product ID: A unique identifier for the product.
Center: The FDA center responsible for the recall.
Recall Details: A URL pointing to more details about the recall.
FEI Number: A unique identifier for the firm recalling a product.
Recalling Firm Name: The name of the firm recalling a product.
Product Type: The type of product being recalled, such as food/cosmetics or biologics.
Product Classification: The classification of the product, e.g. Class I or Class II.
Status: The status of the recall, whether it's ongoing or has been terminated.
Distribution Pattern: Information about where the product was distributed.
Recalling ,Recalling Firm State,Recalling Firm Country: The location of the recalling firm.
Center Classification Date: The date when the recall was classified.
Reason for Recall: The reason why the product was recalled.
Product Description: A description of the product.
Event ID: A unique identifier for the recall event.
Event Classification: The classification of the recall event.
Product ID: A unique identifier for the product.
Center: The FDA center responsible for the recall.
Recall Details: A URL pointing to more details about the recall.
Now, let's dive into the data analysis and generate some creative insights and visualizations. We might want to look at:
Distribution of product types in the recall data.
The most common reasons for recalls.
Trend over time of recalls.
The geographical distribution of recalls.
Classification of recalls and their distribution.
Distribution of product types in the recall data.
The most common reasons for recalls.
Trend over time of recalls.
The geographical distribution of recalls.
Classification of recalls and their distribution.
Let's start by checking the distribution of product types. We'll use a creative circular bar plot to visualize this. For this, we'll need to calculate the number of recalls for each product type.
The dataset contains recalls for six types of products:
Devices: 29,705 recalls
Food/Cosmetics: 24,138 recalls
Drugs: 15,144 recalls
Biologics: 11,059 recalls
Veterinary: 3,101 recalls
Tobacco: 8 recalls
Devices: 29,705 recalls
Food/Cosmetics: 24,138 recalls
Drugs: 15,144 recalls
Biologics: 11,059 recalls
Veterinary: 3,101 recalls
Tobacco: 8 recalls
Next, we will represent this data with a circular bar plot for a creative visualization. However, due to the environment limitations, I can describe how to create a circular bar plot, but I'm unable to generate it here.
In Python, using thematplotliblibrary, we can create a circular bar plot by first creating a standard bar plot on a polar axis. Here's a simplified example:
────────────────────────────────────────────────────────────────────
pythonCopy codeimport matplotlib.pyplot as plt
import numpy as np
Number of bars
n = len(product_type_counts)
Compute angle of each bar
theta = nspace(0.0, 2 * np.pi, n, endpoint=False)
Create a polar subplot
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
Create bars
bars = ax.bar(theta, product_type_counts, width=0.8/n)
Set the lable of each bar to the corresponding product type
ax.set_xticks(theta)
ax.set_xticklabels(product_type_counts.index)
Display the plot
plt.show()
In the code above, we're using thebarfunction of the polar subplotaxto create the bars. Thethetaparameter specifies the angles of the bars, and theproduct_type_countsparameter specifies the length of the bars. We set the width of the bars to be proportional to the number of bars, so that they're evenly distributed around the circle.
This will result in a circular bar plot where each bar represents a product type and the length of the bar represents the number of recalls of that product type.
Next, let's move on to the second insight - the most common reasons for recalls. We can analyze the 'Reason for Recall' column to identify common words or phrases. For this, we'll use a word cloud visualization.
The word cloud visualization above displays the most common words found in the "Reason for Recall" column. The size of a word in the visualization is proportional to the frequency of the word in the dataset.
Key words that stand out include "product", "potential", "presence", "contamination", "may", "labeling", "incorrect", and "lack". This suggests that many recalls are due to potential contamination, incorrect labeling, or lack of something in the product.
For the third insight, let's examine the trend of recalls over time. We'll create a line plot where the x-axis represents time (specifically, the 'Center Classification Date'), and the y-axis represents the number of recalls. We'll also break down the plot by 'Product Type' to see how the trends differ for different types of products. But first, we need to process the 'Center Classification Date' column, as it seems to be of string type. Let's convert it into datetime and then generate the line plot.
Apologies for the mistake in the code. It seems there's a syntax error due to the space in the column nameProduct Type. Let's correct it and try again.
The line chart above shows the trend of product recalls over time for each product type. From the chart, we can observe several insights:
The number of recalls for all product types fluctuates over time, with some periods having more recalls than others.
The "Devices" product type consistently has the highest number of recalls throughout the period.
The "Tobacco" product type has the fewest recalls, barely visible in the chart.
The number of recalls for all product types fluctuates over time, with some periods having more recalls than others.
The "Devices" product type consistently has the highest number of recalls throughout the period.
The "Tobacco" product type has the fewest recalls, barely visible in the chart.
For our fourth insight, let's analyze the geographical distribution of the recalls. We will focus on the 'Recalling Firm State' and create a heat map to visualize the number of recalls in each state. However, due to the environment limitations, I can describe how to create such a visualization but I'm unable to generate it here.
To create a heat map of , we would use a library likegeopandasorplotly. Here's a simplified example usingplotly:
────────────────────────────────────────────────────────────────────
pythonCopy codeimport plotly.graph_objects as go
Count the number of recalls in each state
state_counts = data['Recalling Firm State'].value_counts()
Create a dictionary where the keys are the state abbreviations and the values are the recall counts
state_dict = state_counts.to_dict()
Use the 'usa' colorscale
colorscale = ["#f7fbff","#ebf3fb","#deebf7","#d2e3f3","#c6dbef","#b3d2e9","#9ecae1",
"#85bcdb","#6baed6","#57a0ce","#4292c6","#3082be","#2171b5","#1361a9",
"#08519c","#0b4083","#08306b"]
Create a layout
layout = = 'FDA Product Recalls by State',
geo_scope='usa', # limite map scope to
)
Create the figure
fig = gure(data = go.Choropleth(
locations = list(state_dict.keys()), # Spatial coordinates
z = list(state_dict.values()), # Data to be color-coded
locationmode = '-states', # set of locations match entries in locations
colorscale = colorscale,
colorbar_title = "Number of Recalls",
),
layout = layout)
Display the figure
fig.show()
In the code above, we're creating aChoroplethtrace, which is a type of map where areas are colored according to a variable's value. Thelocationsparameter specifies the state abbreviations, and thezparameter specifies the number of recalls in each state.
Finally, for our fifth insight, let's look at the distribution of recalls by their classification. We'll create a stacked bar plot to visualize this. But first, we need to calculate the number of recalls for each classification and product type.
The dataset contains recalls for three classes:
Class I: Most serious type of recall where there is a reasonable probability that the use of, or exposure to, a violative product will cause serious adverse health consequences or death.
Class II: Recall where exposure to a violative product may cause temporary or medically reversible adverse health consequences or where the probability of serious adverse health consequences is remote.
Class III: Recall where exposure to a violative product is not likely to cause adverse health consequences.
Class I: Most serious type of recall where there is a reasonable probability that the use of, or exposure to, a violative product will cause serious adverse health consequences or death.
Class II: Recall where exposure to a violative product may cause temporary or medically reversible adverse health consequences or where the probability of serious adverse health consequences is remote.
Class III: Recall where exposure to a violative product is not likely to cause adverse health consequences.
For each product type, the recalls have been classified into these three classes. Let's visualize this using a stacked bar plot. A stacked bar plot will allow us to easily compare the total number of recalls by product type, as well as the distribution of recalls by class within each product type.
This stacked bar chart provides a visual comparison of the number of recalls by product type and classification. From the chart, we can observe:
Devices have the highest number of Class II recalls.
Food/Cosmetics have a significant number of both Class I and Class II recalls.
Most of the recalls for Biologics are of Class II.
Veterinary products have a relatively balanced distribution of Class I and Class II recalls.
All the recalls for Tobacco are of Class II.
Class III recalls are considerably fewer across all product types.
Devices have the highest number of Class II recalls.
Food/Cosmetics have a significant number of both Class I and Class II recalls.
Most of the recalls for Biologics are of Class II.
Veterinary products have a relatively balanced distribution of Class I and Class II recalls.
All the recalls for Tobacco are of Class II.
Class III recalls are considerably fewer across all product types.
To summarize the creative insights derived from this analysis:
The majority of product recalls are for Devices, followed by Food/Cosmetics, Drugs, and Biologics. Veterinary products and Tobacco have considerably fewer recalls.
Common reasons for recalls include potential contamination, incorrect labeling, or lack of something in the product.
The number of recalls for all product types fluctuates over time, with Devices consistently having the highest number of recalls.
The geographical distribution of recalls varies across states, and this could be visualized using a heat map.
The distribution of recalls by their classification differs by product type. Most recalls are of Class II, but Food/Cosmetics have a significant number of Class I recalls as well.
The majority of product recalls are for Devices, followed by Food/Cosmetics, Drugs, and Biologics. Veterinary products and Tobacco have considerably fewer recalls.
Common reasons for recalls include potential contamination, incorrect labeling, or lack of something in the product.
The number of recalls for all product types fluctuates over time, with Devices consistently having the highest number of recalls.
The geographical distribution of recalls varies across states, and this could be visualized using a heat map.
The distribution of recalls by their classification differs by product type. Most recalls are of Class II, but Food/Cosmetics have a significant number of Class I recalls as well.
These creative visualizations and insights can help stakeholders understand the patterns and trends in FDA product recalls, inform risk management strategies, and improve product safety.