Time Series Analysis with Python Cookbook by Tarek A. Atwan
Author:Tarek A. Atwan
Language: eng
Format: epub
Publisher: Packt Publishing Ltd.
Published: 2022-06-10T00:00:00+00:00
How it works...
The modified z-score (robust z-score) method is very similar to the z-score approach, as it depends on defining a standard deviation threshold. What makes this method more robust to outliers is the use of the median instead of the mean. We also use the median absolute deviation (MAD) instead of the standard deviation.
There's more...
In the previous recipe, Detecting outliers using a z-score, we used kstest_normal from statsmodels to test normality.
Another helpful plot that is specifically designed to test for normality and sometimes can help detect outliers is the Quantile-Quantile plot (QQ-plot).
You can plot a QQ-plot using SciPy or statsmodels. Both will produce the same plot. The following code will show you can plot using either.
This shows how you can plot using SciPy:
import scipy
import matplotlib.pyplot as plt
res = scipy.stats.probplot(tx.values.reshape(-1), plot=plt)
This shows how you can plot using statsmodels:
from statsmodels.graphics.gofplots import qqplot
qqplot(tx.values.reshape(-1), line='s')
plt.show()
Both SciPy and statsmodels will produce the following plot:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Access | Data Mining |
Data Modeling & Design | Data Processing |
Data Warehousing | MySQL |
Oracle | Other Databases |
Relational Databases | SQL |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8048)
Learning SQL by Alan Beaulieu(5733)
Weapons of Math Destruction by Cathy O'Neil(5386)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(4873)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(4870)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(4745)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(4518)
Driving Data Quality with Data Contracts by Andrew Jones(4441)
Big Data Analysis with Python by Ivan Marin(4297)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(4220)
Data Engineering with dbt by Roberto Zagni(3353)
Blockchain Basics by Daniel Drescher(3060)
Solidity Programming Essentials by Ritesh Modi(2975)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(2853)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2752)
Feature Store for Machine Learning by Jayanth Kumar M J(2682)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2667)
Pandas Cookbook by Theodore Petrou(2632)
Mastering Python for Finance by Unknown(2609)