0% found this document useful (0 votes)
6 views21 pages

Phase 3

Uploaded by

beni.kumar1972
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views21 pages

Phase 3

Uploaded by

beni.kumar1972
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Dynamic pricing

visualisation
Introduction
In this analysis, we will explore the power of data
visualization in dynamic pricing, using interactive and dynamic
visualizations to bring data to life and drive business
success.Uncover insights into dynamic pricing with data
visualization. Using Python and popular libraries, we’ll create
interactive visualizations to explore key metrics and trends, bringing
dynamic pricing data to life

Objective
• Identify patterns and trends
• Visualize demand curves
• Analyze price elasticity
• Compare pricing scenarios
• Highlight peak demand periods

Data set description


E-commerce transactions data for 5 products, 3 customer
segments, and 20 locations, with discounts and revenue.
Data Characteristics:
• 10,000 transactions
• 6 months of data (Jan-Jun)
• Discounts: 5-20%
• Prices: $100-$2,000
This dataset is designed for data visualization techniques to analyze
dynamic pricing strategies and optimize revenue.

Data visualization techniques:


Univariate visualisation
• Line Plot: Helps to visualize trends and patterns in the pricing
data over time.
• Histogram: Shows the frequency distribution of prices,
indicating common price points and the spread of prices.
• Box Plot: Provides insights into the range, median, quartiles,
and potential outliers in the pricing data.
Program code
Import pandas as pd
Import numpy as np
Import matplotlib.pyplot as plt
Import seaborn as sns

# Sample data: Let’s create a DataFrame with date and price


Data = {
‘date’: pd.date_range(start=’2023-01-01’, periods=100,
freq=’D’),
‘price’: np.random.uniform(low=50, high=150, size=100) #
Generating random prices
}
Df = pd.DataFrame(data)
# Plotting the price over time
Plt.figure(figsize=(10, 6))
Sns.lineplot(data=df, x=’date’, y=’price’)
Plt.title(‘Dynamic Pricing Over Time’)
Plt.xlabel(‘Date’)
Plt.ylabel(‘Price’)
Plt.show()
# Plotting the distribution of prices
Plt.figure(figsize=(10, 6))
Sns.histplot(df[‘price’], bins=20, kde=True)
Plt.title(‘Price Distribution’)
Plt.xlabel(‘Price’)
Plt.ylabel(‘Frequency’)
Plt.show()
# Box plot to show price variability
Plt.figure(figsize=(10, 6))
Sns.boxplot(x=df[‘price’])
Plt.title(‘Price Variability’)
Plt.xlabel(‘Price’)
Plt.show()
Output
Bivariate visualisation
Data Preparation: Random prices and demand values are
generated. A slight positive correlation is added between prices
and demand for demonstration.
Scatter Plot:A scatter plot is created to visualize the relationship
between price and demand.
Line Plot:Line plots are created to show the trends of price and
demand over time on the same graph.
Heatmap:A heatmap is created to show the correlation between
price and demand.
Pair Plot:A pair plot is created to visualize relationships and
distributions between the variables.
Program code
Import pandas as pd
Import numpy as np
Import matplotlib.pyplot as plt
Import seaborn as sns

# Generate sample data


Np.random.seed(42) # For reproducibility
Dates = pd.date_range(start=’2023-01-01’, periods=100, freq=’D’)
Prices = np.random.uniform(low=50, high=150, size=100)
Demand = np.random.uniform(low=20, high=100, size=100) + 0.1
* (prices – 100)
Df = pd.DataFrame({
‘date’: dates,
‘price’: prices,
‘demand’: demand
})

# Scatter plot: Price vs Demand


Plt.figure(figsize=(10, 6))
Sns.scatterplot(data=df, x=’price’, y=’demand’)
Plt.title(‘Price vs Demand’)
Plt.xlabel(‘Price’)
Plt.ylabel(‘Demand’)
Plt.show()

# Line plot: Price and Demand over Time


Plt.figure(figsize=(10, 6))
Sns.lineplot(data=df, x=’date’, y=’price’, label=’Price’)
Sns.lineplot(data=df, x=’date’, y=’demand’, label=’Demand’,
color=’orange’)
Plt.title(‘Price and Demand Over Time’)
Plt.xlabel(‘Date’)
Plt.ylabel(‘Value’)
Plt.legend()
Plt.show()

# Heatmap: Correlation between Price and Demand


Correlation = df[[‘price’, ‘demand’]].corr()
Plt.figure(figsize=(8, 6))
Sns.heatmap(correlation, annot=True, cmap=’coolwarm’, vmin=-
1, vmax=1)
Plt.title(‘Correlation between Price and Demand’)
Plt.show()

# Pair plot to see relationships and distributions


Sns.pairplot(df[[‘price’, ‘demand’]])
Plt.suptitle(‘Pair Plot of Price and Demand’, y=1.02)
Plt.show()
Output
Multivariate visualisation
Data Preparation:Random prices, demand, and competitor
prices are generated.A slight positive correlation is added between
prices and demand for demonstration.
Pair Plot:A pair plot is created to visualize the relationships and
distributions among price, demand, and competitor price.
Heatmap:A heatmap is created to show the correlation among
price, demand, and competitor price.
Joint Plot:A joint plot with a regression line is created to visualize the
relationship between price and demand.
3D Scatter Plot:A 3D scatter plot is created to visualize the
relationships among price, demand, and competitor price in three
dimensions.
Program code
Import pandas as pd
Import numpy as np
Import matplotlib.pyplot as plt
Import seaborn as sns

# Generate sample data


Np.random.seed(42)
Dates = pd.date_range(start=’2023-01-01’, periods=100, freq=’D’)
Prices = np.random.uniform(low=50, high=150, size=100)
Demand = np.random.uniform(low=20, high=100, size=100) + 0.1 *
(prices – 100)
Competitor_prices = prices * np.random.uniform(low=0.8, high=1.2,
size=100)

Df = pd.DataFrame({
‘date’: dates,
‘price’: prices,
‘demand’: demand,
‘competitor_price’: competitor_prices
})

# Pair plot
Sns.pairplot(df[[‘price’, ‘demand’, ‘competitor_price’]])
Plt.suptitle(‘Pair Plot of Price, Demand, and Competitor Price’,
y=1.02)
Plt.show()

# Heatmap
Plt.figure(figsize=(8, 6))
Sns.heatmap(df.corr(), annot=True, cmap=’coolwarm’, vmin=-1,
vmax=1)
Plt.title(‘Correlation between Price, Demand, and Competitor Price’)
Plt.show()

# Joint plot
Sns.jointplot(data=df, x=’price’, y=’demand’, kind=’reg’)
Plt.suptitle(‘Joint Plot of Price vs Demand’, y=1.02)
Plt.show()
Output
Interactive visualisation
It will create an interactive scatter plot using Plotly, where you
can hover over each data point to see additional information like
date and competitor price. You can pan, zoom, and interact with the
plot dynamically.
Program code
Import pandas as pd
Import numpy as np
Import plotly.express as px
# Generate sample data
Np.random.seed(42)
Dates = pd.date_range(start=’2023-01-01’, periods=100, freq=’D’)
Prices = np.random.uniform(low=50, high=150, size=100)
Demand = np.random.uniform(low=20, high=100, size=100) + 0.1 *
(prices – 100)
Competitor_prices = prices * np.random.uniform(low=0.8, high=1.2,
size=100)

Df = pd.DataFrame({
‘date’: dates,
‘price’: prices,
‘demand’: demand,
‘competitor_price’: competitor_prices
})

# Scatter plot with Plotly


Fig = px.scatter(df, x=’price’, y=’demand’, hover_data=[‘date’,
‘competitor_price’], title=’Price vs Demand’)
Fig.show()
Output
Program for interactive dashboard:
Import dash
From dash import dcc, html
Import pandas as pd
Import numpy as np
Import plotly.express as px

# Generate sample data


Np.random.seed(42)
Dates = pd.date_range(start=’2023-01-01’, periods=100, freq=’D’)
Prices = np.random.uniform(low=50, high=150, size=100)
Demand = np.random.uniform(low=20, high=100, size=100) + 0.1 *
(prices – 100)
Competitor_prices = prices * np.random.uniform(low=0.8, high=1.2,
size=100)

Df = pd.DataFrame({
‘date’: dates,
‘price’: prices,
‘demand’: demand,
‘competitor_price’: competitor_prices
})
# Initialize the Dash app
App = dash.Dash(__name__)
# Define the layout of the dashboard
App.layout = html.Div([
Html.H1(“Dynamic Pricing Dashboard”),
dcc.Graph(id=’scatter-plot’),
dcc.Graph(id=’line-plot’),
])
# Define callback functions to update the plots based on user
interactions
@app.callback(
[dash.dependencies.Output(‘scatter-plot’, ‘figure’),
Dash.dependencies.Output(‘line-plot’, ‘figure’)],
[dash.dependencies.Input(‘scatter-plot’, ‘hoverData’)]
)
Def update_plots(hoverData):
# Get the selected point from the scatter plot
If hoverData is not None:
Selected_date = hoverData[‘points’][0][‘x’]
Selected_data = df[df[‘date’] == selected_date]
# Create scatter plot
Scatter_fig = px.scatter(selected_data, x=’price’, y=’demand’,
title=’Price vs Demand’)
# Create line plot
Line_fig = px.line(selected_data, x=’date’, y=’price’, title=’Price
Over Time’)

Return scatter_fig, line_fig


Else:
# If no point is selected, show default plots
Scatter_fig = px.scatter(df, x=’price’, y=’demand’, title=’Price vs
Demand’)
Line_fig = px.line(df, x=’date’, y=’price’, title=’Price Over Time’)
Return scatter_fig, line_fig
# Run the app
If __name__ == ‘__main__’:
App.run_server(debug=True)
Output

Assumed scenario

Scenario: wants to optimize dynamic pricing. They need data


visualization to analyze 3 months of data and:

• Identify demand and revenue patterns


• Analyze discounts and promotions
• Determine optimal prices

Conclusion
Data visualization techniques uncover insights in dynamic
pricing data, enabling FashionForward to optimize prices, maximize
revenue, and stay competitive.

You might also like