Docsity

data analytics, Notas de estudo de Engenharia Elétrica

Toggle sidebar
bg1
Nelli
Shelve in:
Programming Languages/General
User level:
Intermediate
www.apress.com
SOURCE CODE ONLINE
RELATED
BOOKS FOR PROFESSIONALS BY PROFESSIONALS®
Python Data Analytics
Python Data Analytics will help you tackle the world of data acquisition and analysis
using the power of the Python language. At the heart of this book lies the coverage
of pandas, an open source, BSD-licensed library providing high-performance, easy-
to-use data structures and data analysis tools for the Python programming language.
Author Fabio Nelli expertly shows the strength of the Python programming
language when applied to processing, managing and retrieving information. Inside,
you will see how intuitive and flexible it is to discover and communicate meaningful
patterns of data using Python scripts, reporting systems, and data export. This book
examines how to go about obtaining, processing, storing, managing and analyzing
data using the Python programming language.
You will use Python and other open source tools to wrangle data and tease out
interesting and important trends in that data that will allow you to predict future
patterns. Whether you are dealing with sales data, investment data (stocks, bonds,
etc.), medical data, web page usage, or any other type of data set, Python can be
used to interpret, analyze, and glean information from a pile of numbers and statistics.
This book is an invaluable reference with its examples of storing and accessing
data in a database; it walks you through the process of report generation; it provides
three real world case studies or examples that you can take with you for your
everyday analysis needs.
• How to set up your environment and use automation scripts
• Where and how to get your data
• How to analyze your data with Python’s data analysis library, called pandas
• How to carry out visualization with matplotlib
• How to analyze text data using Python’s natural language processing
9781484 209592
54999
ISBN 978-1-4842-0959-2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Pré-visualização parcial do texto

Baixe data analytics e outras Notas de estudo em PDF para Engenharia Elétrica, somente na Docsity!

Python Data Analytics

Data Analysis and Science Using

Pandas, matplotlib, and the

Python Programming Language

Fabio Nelli

iii

Contents at a Glance

About the Author ���������������������������������������������������������������������������������������������������xvii

About the Technical Reviewer ��������������������������������������������������������������������������������xix

Acknowledgments ��������������������������������������������������������������������������������������������������xxi

■Chapter 1: An Introduction to Data Analysis ��������������������������������������������������������� 1

■Chapter 2: Introduction to the Python’s World ���������������������������������������������������� 13

■Chapter 3: The NumPy Library����������������������������������������������������������������������������� 35

■Chapter 4: The pandas Library—An Introduction ������������������������������������������������ 63

■Chapter 5: pandas: Reading and Writing Data��������������������������������������������������� 103

■Chapter 6: pandas in Depth: Data Manipulation ������������������������������������������������ 131

■Chapter 7: Data Visualization with matplotlib ��������������������������������������������������� 167

■Chapter 8: Machine Learning with scikit-learn ������������������������������������������������� 237

■Chapter 9: An Example—Meteorological Data �������������������������������������������������� 265

■Chapter 10: Embedding the JavaScript D3 Library in IPython Notebook ��������� 289

■Chapter 11: Recognizing Handwritten Digits����������������������������������������������������� 311

■Appendix A: Writing Mathematical Expressions with LaTeX ����������������������������� 317

■Appendix B: Open Data Sources ������������������������������������������������������������������������ 327

Index ��������������������������������������������������������������������������������������������������������������������� 331

v

Contents

About the Author ���������������������������������������������������������������������������������������������������xvii

About the Technical Reviewer ��������������������������������������������������������������������������������xix

vii

viii

x

xi

xiii

xiv

xvii

About the Author

Fabio Nelli is an IT Scientific Application Specialist at IRBM Science Park, a private research center in Pomezia, Roma (Italy). He has been a computer consultant for many years at IBM, EDS, Merck Sharp, and Dohme, along with several banks and insurance companies. He has an Organic Chemistry degree and many years of experience in Information Technologies and Automation Systems applied to Life Sciences (Tech Specialist at Beckman Coulter Italy and Spain). He is currently developing Java applications that interface Oracle databases with scientific instrumentations, generating data and Web server applications and providing analysis of the results to researchers in real time. Moreover, he is the coordinator of the Meccanismo Complesso community (www.meccanismocomplesso.org).

xix

About the Technical Reviewer

Shubham Singh Tomar is a Data Engineer at Predikt.co. He lives and works in Bangalore, India. On weekends he volunteers to work on Data Science projects for NGOs and social organizations with the Bangalore chapter of. He writes about Python, Data Science and Machine Learning on his blog: shubhamtomar.me.

1

Chapter 1

An Introduction to Data Analysis

With this chapter, you will begin to take the first steps in the world of data analysis, seeing in detail all the concepts and processes that make up this discipline. The concepts discussed in this chapter will be helpful background for the following chapters, where these concepts and procedures will be applied in the form of Python code, through the use of several libraries that will be discussed in just as many chapters.

Data Analysis In a world increasingly centralized around information technology, huge amounts of data are produced and stored each day. Often these data come from automatic detection systems, sensors, and scientific instrumentation, or you produce them daily and unconsciously every time you make a withdrawal from the bank or make a purchase, when you record on various blogs, or even when you post on social networks. But what are the data? The data actually are not information, at least in terms of their form. In the formless stream of bytes, at first glance it is difficult to understand their essence if not strictly the number, word, or time that they report. Information is actually the result of processing, which taking into account a certain set of data, extracts some conclusions that can be used in various ways. This process of extracting information from the raw data is precisely data analysis. The purpose of data analysis is precisely to extract information that is not easily deducible but that, when understood, leads to the possibility of carrying out studies on the mechanisms of the systems that have produced them, thus allowing the possibility of making forecasts of possible responses of these systems and their evolution in time. Starting from a simple methodical approach on data protection, data analysis has become a real discipline leading to the development of real methodologies generating models. The model is in fact the translation into a mathematical form of a system placed under study. Once there is a mathematical or logical form able to describe system responses under different levels of precision, you can then make predictions about its development or response to certain inputs. Thus the aim of data analysis is not the model, but the goodness of its predictive power. The predictive power of a model depends not only on the quality of the modeling techniques but also on the ability to choose a good dataset upon which to build the entire data analysis. So the search for data , their extraction , and their subsequent preparation , while representing preliminary activities of an analysis, also belong to the data analysis itself, because of their importance in the success of the results. So far we have spoken of data, their handling, and their processing through calculation procedures. In parallel to all stages of processing of the data analysis, various methods of data visualization have been developed. In fact, to understand the data, both individually and in terms of the role they play in the entire data set, there is no better system than to develop the techniques of graphic representation capable of transforming information, sometimes implicitly hidden, in figures, which help you more easily understand their meaning. Over the years lots of display modes have been developed for different modes of data display: the charts.

Chapter 1 ■ an IntroduCtIon to data analysIs

2

At the end of the data analysis, you will have a model and a set of graphical displays and then you will be able to predict the responses of the system under study; after that, you will move to the test phase. The model will be tested using another set of data for which we know the system response. These data are, however, not used for the definition of the predictive model. Depending on the ability of the model to replicate real observed responses, you will have an error calculation and a knowledge of the validity of the model and its operating limits. These results can be compared with any other models to understand if the newly created one is more efficient than the existing ones. Once you have assessed that, you can move to the last phase of data analysis—the deployment. This consists of the implementation of the results produced by the data analysis, namely, the implementation of the decisions to be taken based on the predictions generated by the model and the risks that such a decision will also be predicted. Data analysis is a discipline that is well suited to many professional activities. So, knowledge of what it is and how it can be put into practice will be relevant for consolidating the decisions to be made. It will allow us to test hypotheses, and to understand more deeply the systems analyzed.

Knowledge Domains of the Data Analyst Data analysis is basically a discipline suitable to the study of problems that may occur in several fields of applications. Moreover, in processes of data analysis you have many tools and methodologies that require good knowledge of computing and mathematical and statistical concepts. So a good data analyst must be able to move and act in many different disciplinary areas. Many of these disciplines are the basis of the methods of data analysis, and proficiency in them is almost necessary. Knowledge of other disciplines is necessary depending on the area of application and study of the particular data analysis project you are about to undertake, and, more generally, sufficient experience in these areas can just help you better understand the issues and the type of data needed to start with the analysis. Often, regarding major problems of data analysis, it is necessary to have an interdisciplinary team of experts made up of members who are all able to contribute in the best possible way in their respective fields of competence. Regarding smaller problems, a good analyst must be able to recognize problems that arise during data analysis, inquire to find out which disciplines and skills are necessary to solve the problem, study these disciplines, and maybe even ask the most knowledgeable people in the sector. In short, the analyst must be able to know how to search not only for data, but also for information on how to treat them.

Computer Science

Knowledge of Computer Science is a basic requirement for any data analyst. In fact, only one who has good knowledge of and experience in Computer Science is able to efficiently manage the necessary tools for data analysis. In fact, all the steps concerning the data analysis involve the use of computer technology as calculation software (such as IDL, Matlab, etc.) and programming languages (such as C ++, Java, Python). The large amount of data available today thanks to information technology requires specific skills in order to be managed as efficiently as possible. Indeed, data research and extraction require knowledge of the various formats. The data are structured and stored in files or database tables with particular formats. XML, JSON, or simply XLS or CSV files are now the common formats for storing and collecting data, and many applications also allow their reading and managing data stored on them. For the extraction of data contained in a database, things are not so immediate, but you need to know SQL query language or use software specially developed for the extraction of data from a given database. Moreover, for some specific types of data research, the data are not available in a pre-treated and explicit format, but are present in text files (documents, log files) or in web pages, shown as charts, measures, number of visitors, or HTML tables that require specific technical expertise for the parsing and the eventual extraction of these data ( Web Scraping ).