Friday, August 28, 2020

Power Bi or Tableau || Visualization

Visualization is nowadays one of the most important fields within analytics domain. To get handy insights and develop an understanding i.e. exploratory analysis it is best to do some quick visualization to see the big picture. And once we are done with data preprocessing, some cool visualizations help us in developing better understanding of our products, customer, geographies etc. Also now we have strong tools from Tableau to Power Bi which give us more than just visualization but also analytics within the tools. 

Lets start: You first need to download the free version for Power BI Desktop and start practicing. I will post some tutorials over next couple of weeks to bring you to speed with latest and robust features in Power Bi. You can also download Tableau Public for free. Although these free version do not have full features but they can give you a very good platform for training purposes.

Tableau Visuals



Power Bi Visual




While Tableau may look easy to use to some users, Power bi has strong capabilities in terms of modeling your data. Structuring your data maybe easier in Power Bi since it uses Excel like features. You may also use Alteryx for preprocessing and then send data to SQL server to load into either power bi or tableau or you can even download as excel or csv post Alteryx and then upload to Tableau or Power Bi. 

For calculations, you need to create calculated fields in Tableau, and measures in Power Bi. Measures might need some understanding of the M language. While both tools give shortcuts to create measures and calculated fields. But more than 90% of the time you go about creating custom measures and calculated fields. There are many custom visuals in Power Bi which give amazing visualization features such as Gantt charts, candle sticks etc.

Creating Measure in power bi
newSales = SUMX(Salestable,Salestable[Amount]*[newprice])

Calculated fields in Tableau
newSales = [amount]*[newprice]

While you need to give context filters within Dax measures in power bi. You can simply enable
add to context feature in filter in Tableau.

Both tools are amazing in their own way. You can chose one and get started with learning and once you have hands on experience,
you can easily get to another tool.

Thanks

Time Series Forecasting using fbprophet in Python

Hello friends. Today I am going to talk about time series forecasting using one of the best tools that we have in open source projects i.e. fbprophet. You can read more about it with documentation at the hyperlink. 'fbprophet' implements a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality and on top of that gives flexibility for holiday effects.

So lets start, I have chosen a kaggle dataset to predict the sales of stores. You can probably download the dataset and practice along for a better understanding. 

Importing the necessary libraries: As always



But most importantly, it will ask you to install a few packages as 99% chances are, you wont have these packages installed. So you need to install in Ananconda prompt using pip install. For e.g.


Step 2: Plotting the data

plt.subplots(1, figsize = (16, 5))

plt.grid()

plt.title('Store 1 - All Sales')

for item in set(df_raw[df_raw['store'] == 1]['item']):

    plt.plot(df_raw[(df_raw['store'] == 1) & 

                    (df_raw['item'] == item)]['sales'].rolling(window=50).mean())



Step 3: Preparing the data into Fbprophet format

train_dataset = df_raw[(df_raw['item'] == 1) & df_raw['store'] == 1] 

train_dataset.reset_index(level=0, inplace=True)

train_dataset = train_dataset[['date', 'sales']]

train_dataset.columns = ["ds", "y"]

train_dataset = train_dataset.sample(5000)

prophet_basic = Prophet()

prophet_basic.fit(train_dataset)

Step 4: Forecasting 1 year ahead

future= prophet_basic.make_future_dataframe(periods=365)

future

Step 5: And here you go with the forecast

You can visualize the various components i.e. yearly and weekly trends

fig1 = prophet_basic.plot_components(forecast)


Visualize with even further additions to the plot.

So time series analysis is now simple and robust with fbprophet. You just need to have the right set of data.

Since we are talking a lot about visualization within data analytics, so maybe I will come up with a post on amazing Tableau visualizations next.


Thanks,