top of page

Python Data Analysis Tips - Anomaly Detection Plot in Seaborn




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:









free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, anomaly dectection plot, lineplot, scatterplot, mean, std,, analyze, statical analysis, distribution
Seaborn's lineplot 1st part of anomaly dectection plot

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.


free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, anomaly dectection plot, lineplot, scatterplot, mean, std,, analyze, statical analysis, distribution
pyplot's axhline to make the boundaries

Next we use pyplot's axhline to make the boundary of where an anomaly occurs.



free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, anomaly dectection plot, lineplot, scatterplot, mean, std,, analyze, statical analysis, distribution
Seaborn's scatterplot to highlight anomalies

Next in making our anomaly detection plot we use Seaborn's scatterplot to highlight our anomalies.


free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, anomaly dectection plot, lineplot, scatterplot, mean, std,, analyze, statical analysis, distribution
Call Seaborn's scatterplot twice to color the type of anamoly

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.







51 visualizaciones0 comentarios

留言

評等為 0(最高為 5 顆星)。
暫無評等

新增評等
bottom of page