In Python with Seaborn learn how to make an anomaly detection plot. In this example, we use the Google stock price movement in our anomaly detection plot in Seaborn. Stock prices are prone to high volatility and as a portfolio manager, it can be helpful having the ability to detect anomalous movements.
To make an anomaly detection plot we will we use several Seaborn plots together. In this we use 3 different types of plots. Seaborn's lineplot, Seaborn's scatterplot and matplotlib.pyplot's axhlineplot to make our anomaly detection plot.
Here we have set up our anomaly detection plot to highlight the Google Stock prices have a percentage change greater or less than 3 standard deviations from the mean.
With the flexibility of Seaborn we will also be can to change the color depending on if the outlier is a high or low side anomaly.
Follow Data Science Teacher Brandyn
dataGroups:
To make our anomaly dectection plot in Seaborn we start with a lineplot in Seaborn to plot the historical stock price percentage change of the Google Stock.
Next we use pyplot's axhline to make the boundary of where an anomaly occurs.
Next in making our anomaly detection plot we use Seaborn's scatterplot to highlight our anomalies.
Next to emphasize that the anomalies might mean different things we highlight our anomalies with different colors. We do this by calling Seaborn's scatterplot two times while using Pandas' logical indexing to select which side get which color.
留言