Neural Prophet – A powerful AI framework for Time Series Models

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
talks due to start in um in a few seconds but we're going to wait um a minute or so um for people to wander in from the the break and then once that's done um uh i want to start the talk i'll hand over to you and you can drive the screen and all the rest of it okay so once i start sharing screen then i can simply go ahead right yeah i'd say i'll do a brief introduction i'll take off this um this overlay slide and you can share your screen and then you can go [Music] so it's uh something i got a last-minute opportunity i checked the schedule and i've seen there was a when the top was cancelled so i thought i was thinking with organizers and unfortunately i got accepted so i'm so happy for that sort of people are starting to trickle in to watch the the youtube stream um so i'll just give it another 30 seconds and then we can start all right i think we can start welcome to the first talk in video room 2 of the afternoon session our speaker is kenyan who has very kindly stepped in to replace our scheduled speaker who unfortunately had to pull out because of a family emergency so we're very grateful and we look forward to an interesting talk share your screen you can take it away [Music] all right so we are good to go yep you're good to go all right hello everyone and uh thank you so much for giving me the opportunity in the last moment and i'm so happy to speak to you at uh today so today i'm going to talk about the new profit a powerful ai framework for time series models myself a healthcare data scientist and analytics manager and i'm also a community first person so i love involving being with realistic communities and i like community by sharing my knowledge whatever i know so that's how i look for opportunities to speak and i'm also a lifelong learner and mentor so that's pretty much about me and here is the agenda for today's talk so some action about neural profit and finally we'll conclude our topic so feel free to drop your questions if you have anything at any point of time each and every question and then okay without any further delay let's get started so what is kind series there are so many definitions on the internet of the time series out of which indicates same meaning in a different way a very straightforward definition is sequential data order matters time series is a sequence of observation taken sequentially in time when forecasting time series data the main aim is to estimate how sequence of observations will continue in future so observations are typically collected at regular intervals like every week daily yearly monthly etcetera for example if you are talking about weather data we will receive weather updates for every 10 minutes or every one hour or if you are talking something about iot sensors like that so that generate data continuously so depending upon the source of the generation we may have different frequencies at which data is collected advancements in machine learning have increased the value of time series because there are so many prediction problems that involve and serious component that is why it is like booming in the industry now argumentations apply machine learning to time freeze data to make informed business decisions they do forecasting they compare cycling forecasting helps us to predict the future values of a critical field which has a potential business value in the industry for example printing the health condition of a person or predicting the performance of sport or creating the performance of a player based on the previous data or something like that i believe that time theory has spread his rings completely so that is why it is there everywhere in every industry now here comes our main topic neural profile so here is a visual representation about neural profit so it is a python library for a time zone forecasting neural profit is a neural network based model that uses white touch as a back-end and it has a modular architecture that allows so many features to be plotted in the future and this library is heavily inspired from facebook profit in air net libraries and the author of this libraries are the researchers from stanford university and monash university what more we need to know about neural profit this library is absolutely a business friendly one can easily set up and start building time series models which you'll see in some time addresses paying points such as scale customization and extensibility this library is completely scalable you can also customize or modify or adjust your model according to your needs and and of course you can also manipulate or edit your core without changing your existing core base so that's the beauty of this library just like profit your profit is also decomposable with all the time seriously components like you know trends seasonality auto regressive lag future rigorous and economic recurring events this library means absolutely an upgraded version of profit because it uses deep learning models such as air net for forecasting time series models now why we need neural profit it tends to solve the sees of uncertainty so what do i mean here so i assume you are aware of auto regressive models alpha regressive models are nothing new but usually you would treat a linear regression you would use a linear regression field with a least square instead of a neural network with a back propagation it is a single layer network that is trained to mimic the air processing the time series signal but at a very large scale than the traditional air and the traditional models air net also scales much better to larger data sets and more inputs for example if you look at this below graph the training time of a auto regression doesn't increase exponentially with a or order so here is a here so the training time doesn't increase exponentially when you compare with a order one thing i would also like to stress here is about the p value so the p values here are the number of order regresses used in the order reducing models not the p values that we use in a null hypothesis testing apart from a r net neural profit also upgrades profit linear external reducers to feed forward neural networks because deeper equals to better so the better the deeper equals better it needs the better we can train our model so the better we'll get an accuracy the better we have more because the learning parameters increases dramatically so to cope with that neural profit relies i touch a height of framework as a back end instead of fan and trade with a stochastic gradient descent that's again an amazing feature now what's the difference first things first as the name suggests neural property is similar to profit but it throws some neural network in the mix to spice up things when you are exploring time series data at any point of time you will definitely encounter a popular package called facebook profit because it takes a lot of popularity due to the fact that it provides a very good result in terms of accuracy and interpretable results the best part of your profit is it automates lot of elements for for example hyper parameter selection feature engineering etc for the users that is why it is very straightforward to use for a data scientist or any other folks who are playing with time series data or even for the folks who have a very less knowledge they can straight and use a topic that's again an amazing feature when it comes to neural profile the author also had the same thing in your mind for this library to retain all the advantages of the profit by improving accuracy and scalability for every so using air net for using arms to combine the scalability of a neural networks with the interpretability of ar models so that's an amazing difference between the profit and load so here are the main goal differences and the features which are available in the neural profit comparatively with the original profit the first one is a gradient decent optimization since neural profit relays by touch as a back end which makes model much faster time series autocorrelation is modeled using the autoregressive neural network and lagged resources are modeled through a separate field forward network so which makes our model even much faster and also additionally the model is configurable to more linear deep layers of network this is again an amazing feature it also offers the custom losses and metrics so which you can see when once we jump into the home apart from these amazing features and the great feature of the neural properties it allows the developer access to the net library which was developed by facebook researchers so that's again an amazing feature of the neural profile so i think i have given an nf gam on cleaning so let's straight away jump into some hands-on and let's see some action now so let me switch to my notebook now all right okay so here is my notebook for this presentation so so the basically the goal of this movie is to show you about renewal again first thing first so to install neural profile there are multiple ways you can do it the straightforward the first thing you can simply install your profit if you want to install your profile you need to install a neural profile this will allow you to enable the line block loss in the fit function to view live plot for more training and validation loss other than this if you want to get an up-to-date version of in your profit so simply go to the github page of a new profit and claim so it's already installed so this demonstration notebook consists of a two section the first section where we'll be creating a simple baseline model of a neural profile and in the section two we'll dig into big detail about neural profit by understanding some additional information on that okay i really will import necessary suspects here so i have imported the libraries called mind as much blood and neural profit i also imported random seed initializing all my libraries now so so for this demonstration purpose i am taking the retail sales retaining same csv data so from the profit github page okay uh all right so let me read my sales data now so we got the first uh rows of our data and let me also run the last tables of our data so here we have a data now so just like profit neural profit also requires y for the parameter which we want to predict so in our case which we have already done so there is no need to do any reformatting here so i think we are good to proceed further now so let's create a simple model so we can simply create we can simply create a model and validate you know very few lines of it so let's see that now so i have initialized regular profit model here and there are so many options and parameters are available which we can punch to neural profile to improve our results but for now we'll keep things simple and let's create a simple baseline model here so i've initialized my neural profit model here and then i am calling my faith function where i am passing my data and other parameters so while you read each epoch one day is nothing but whether or not to validate the model data whether or not to validate the model data for the audition purpose validity is nothing but it's a float point between zero and one indicating that the number of observation should be trained uh on our data frequency is equal to d which is nothing but we are uh we are taking a daily frequency here a lot like the law is nothing but if you get a live word for more training and validation loss you know which you will be seeing in some time now a box is nothing but the number of people which we should be used perfect okay let me run this so now you will see the light block here lot and notice how plot and life loss values are updating after each other so if you want to check again if you want to see again you see how our you know lord and live loss are operating after each other so let's see what it means so i am creating here a future data stream where i'm passing my data and giving period as a 360 so so here i am creating a one year feature data frame for our predictions then i am passing my feature data frame to predict function to return the forecast so once i execute this we will get a feature from data stream so if you remember if you see here our data starts at january 1st 1992 and it ends at uh first may 2016. so if you look at a future data frame it starts at the second may 2016 and it ends with 2017 may 1st so here we got a future data frame here and it also identifies the y hat predictions uh trend and season early values here well that's again an amazing thing here and one thing we should also remember here is it is common for the y and refugeal values to be none so this is an expected behavior so you don't need to get planning on this particular things okay so so we have so far we are good that you know we also got a feature rate of them let's plot our full customer so let me a lot so plotting forecast is pretty straight forward we just need to pass our future data into our model.plot we will get a future plot so this is a one year future plot of our retail sales field data and if you notice that that how the plot is able to learn the seasonal patterns for our retail sales data so another great thing is that you can also plot the model components so so these model components are nothing but so these this process is known as time series d components which i have also discussed in the size slide so you can also see the trend value so it is a solid decreasing trend here for the retail data and if you also look at seasonal clearly it is particularly high in the month of a december comparatively with other months so these time series decomponent plots are really important for domain next particle because they look into these components to visualize to realize and gain insights in the overall forecasting process and based on this they will adjust the model accordingly so this is a very important role for the domain expertise so that's pretty much about you know a simple uh neural profit model so this is how we can create a simple model of a neural problem so let me jump into the next session now so in this section so we'll see why neural property is so powerful because it takes additional information into accounts such as seasonality and recurring events into account so we see all these items one by one in action and you will get to know more about it okay so for this demonstration purpose i am taking a different data set from kaggle which is called a nifty uh 50 index data so in that and then you're considering a marketing company so let me read my data here okay i have written the data so here are the first rows for our data let me also look at the info about the data so here is the info about our [Laughter] so as i mentioned earlier before we passed our model we need to reformat our data frame so so this is what i am doing exactly here so so here is the new variable i'm creating and selecting my new data in my data frame and i'm selecting these two columns from the data that gives an overall value of a price that was traded throughout the trade so this this this price is really helpful for the trader because they get insights into a trend and the value of the security so this plays a very key okay let's look at the trends now so first thing first so let me run this so what i have done is so i have selected uh my new data frame and i've also passed my column which is one limited average file and simply plotting here so if you look at this graph it shows a general increasing trend with some points where price rises or falls sharply so most of the time so it's a solid increasing trend but there are only very careful so where price is is rising and it's falling so we can consider these added change points so with this in mind now we play a neutral profit model of our monthly stock price for the same only trend as our first version of model so we need that so we so we'll build a model only focusing trend as our model thing and let's see how the result looks like so before that so as i mentioned earlier so we need to rename the column so date time should be a ds and our predicted parameters should be as invite so i'm doing the same here so we are all good now let's create a model now so i've initialized the model neural profit and uh passing through parameters so you so with neural profit we can create a focusing time series model by passing a very few parameters here so how specifying the number of points in the broader trend increase of a decrease in the data changes for its like a rate of increase of decrease in the data changes rendering is nothing but it's a regularized parameter that controls the flexibility of the change point selection and if you look at right here this is not the immediacy is 90 degrees 19 because we are focusing only on the trend so that is the reason uh given okay now we have initialized our model now then we are fitting our model so we had our model and also the other parameters so these parameters we have already seen in section one so it took the same let me run my model now okay your so you see the light lot here now the light block lost so if you observe the light looks more compromising but however it seems like it seems like after a lot of volatility the model has converged so in order to understand better so we can visualize our model predictions now but what i've done is i have created a custom function called plot forecast here where i'm passing my model my data periods historical prediction highlight steps ahead periods is nothing but the number of periods which we want to forecast historic trading is nothing but whether we whether to highlight the forecast line it will highlight the forecast line so which is only available for auto reducing models only so so i have created a custom function now then again i'm creating a new feature data frame here so where i am passing my data passing my period historical predictions so once i have created a future data frame now that i am passing my feature data frame to predict function which will return the forecast and here i've also written a quick conditional statement here so if highlight step ahead is not meant for i want my model to highlight the forecast line for each uh otherwise simply plot my forecast predictions so this is what i'm doing so let me run this okay so now so now i have called my function where i'm passing my model my data and giving period as 60. so what does it mean here is now we are visualizing our uh multifocal multispark price on historical data and it also forecasts for the next two months that is 60 years so our so if you observe this graph it is very evident that the model is able to capture the general increase in trend for our morphe stockpiles but however if you observe model seems to say seems to suffer with fitting here particularly in the year 2019 and 2017 so these values are likely used for validation so so let's also look at the forecast plot so we know not the forecast plot where we don't see any historical data we only see in the forecast uh plot line here so if you observe this forecast plot it shows a solid increase in length like a solid straight name so let me tell you something if stock triangular is that easy to predict no one in the organization would generally don't hire a financial advisor to manage their portfolio make sense so it is not easy that it's not that easy to creating the stock list so so what we can do better uh in order to improve our model so we pass some season parameters here to tune our model so let's jump into cinematic now in often most often in time series we see a seasonal pattern so this is even true for a stock market data as well so we so this is what exactly i'm doing here so here i've initiated my model uh then i'm passing in parallel which i have seen the only thing really i am uh making the yearly seasonality of it true rest all remain the same okay once uh then i'm fitting my function uh treating my model then i am passing my all other parameters and once i execute this it looks in the the loss function the loss plot looks so you see the last block looks almost like you know similar but a bit realistic comparatively what we have seen in the trend here okay now let's let's plot our forecast plot here so so let me plot our forecast so if you look at our forecast plot uh and let's also run our you know uh so this is a historical plot including forecast one this is the only exclusive testing plot so based on the about two plots so the model looks a bit realistic but it still suffered with some kind of fitting here and if you look at this forecast plot it shows a smooth curve that reflects a year of a seasonality degree that that reflects the degree of yearly seasonality here but in real time there are very rare instances where stocks move so smoothly if you remember most of the times stock market graphs looks very uneven and that tangent lines it does not look this right or not then perfect spline so these are very rare instances where you see these kind of enterprise very hard instances where you see these kind of you know increase uh smoke servicing so so what we can do better now so we will capture all this volatility will capture all this volatility by using air models such as air net and let's see how our results look like so air net so what we do in this case is so we now forecast our model by considering here net and so so so we want to we want to take the historical data and of 60 days to predict the next 60 days data so so what i mean here is that we've now considered the previous historical data historical studies of the data and based on what historical data will create the next six years data so that is what this parameters n forecast and n lags here so just all other parameters remain the same and i've initialized the model and once uh i've got them i'm treating my model three to four minutes of time to execute all this uh so in time and full configuration and not executing this uh because it takes few more minutes to run all this but you can see here that no it will quickly get all this value so by looking at these numbers it might be a little bit difficult to analyze things so let's uh see the plot here so so this is our lot forecast squad based on history and near future and if you also look at the exclusive forecast plot so based on these two plots based on this uh two plots the air net model looks more realistic here makes more realistic predictions so we can see some more realistic predictions here and it also managed to capture the uneven lines in the movements of the stock market so that's the an amazing beauty of this arc model so it has captured all these uneven links the movements in the stock market so this model is perfect so far i mean like this is at least you know pretty good model comparatively with what we have seen in uh transient seasonality so still we can also improve our model by taking recurring events into the consideration so what do you mean by requirements so most of them by doing forecasting problems we should take real events into the consideration so events are nothing but you know if there are any holidays that are impacting our stock right so this is what we are doing now here so i've initialized my model then i am passing i am contributing my model to take the dates of your holidays into account and see whether we have any impact of our stock price so apart from that i'm also passing two partners which upper window which is nothing but so now i want my model to pay the previous day and the next day of these of the prices impacted prices as well so what i mean here is for example if today is a holiday i want my model to see whether there was any impact on the prices of yesterday and whether there was any impact of tomorrow as well so i want to take those things as also into the consideration so by giving these parameters as well so so that's it uh then again i'm fitting my function so once i execute this we'll also get this uh loss values mean absolute error all these things so let's look at this plot so once i execute our forecast plot here so it looks more realistic again and all you can also look at uh you know the exclusive forecast plot here it still has captured you know some uh uneven things here but when you compare these two lots within your earned lords actually there is no impact in our model i mean like even though it has considered the holidays here so all these years are nothing but you know so it is one thing sorry i forgot to mention it you know all this because uh nifty index are based on a message of people which is an indian fiction that is the reason i have taken indian oil days the thing is it it should also show here that you know what what are the all this which are impacted here so i don't know why it is not showing but in general it will show you the holidays which were impacted on this particular mod but when we look at this result here uh it seems like there is no impact on them the holidays were no more not impacted by our model so it seems like it looks same similar with the ai model so finally what i want to conclude here is predicting stock price is not that easy but however our model has done a good job in terms of capturing a common trend common interesting trend in the moment so that's that's i mean that's a good thing we have done so far uh of course due to the day to day of the stock market i would highly not recommend to use this model for your own trading but i believe that this is a good demonstration of the capabilities of explaining the neural profile lastly there is so much more that you can do with the neural profile but hopefully this is plenty that you know you can get started with a neural profile so that's pretty much about my demonstration let me switch to my slides once [Music] so here is a roadmap for our neural profile so here is a roadmap already foreign and finally here the good [Music] you can check them and yeah that's pretty much from my side thank you it's always more uh it's always good to take the time to take seriously so that's pretty much from my side and if you have any feedback or any comments or any suggestion anything for me feel free to reach out to me on my social media so here are my social media uh here on my channels so it's gonna be flowing twitter and kalyan you can find me on linkedin anything [Music] yeah all right thank you very much for your talk we have about five minutes um for any questions so if anyone does have anything you know how to do that by the discord bot um give people a minute or two see if anyone has any questions uh okay it doesn't look like um we i'm going to get any questions but um thank you again for your talk thank you very much for um stepping in on such notice and yeah [Applause] questions i'll be around so feel free to jump in the discord i'll be happy to answer and thank you so much uh neil and no you are missing see you all later on thank you all right okay in the broadcast yeah
Info
Channel: PyCon South Africa
Views: 210
Rating: undefined out of 5
Keywords:
Id: 18uydaI3Z08
Channel Id: undefined
Length: 41min 21sec (2481 seconds)
Published: Sat Oct 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.