AI News, The Top Mistakes Developers Make When Using Python for Big Data Analytics
- On Monday, June 4, 2018
- By Read More
The Top Mistakes Developers Make When Using Python for Big Data Analytics
##1 Introduction Python is a language universally praised for cutting down development time, but using it efficiently for data analysis is not without its pitfalls.
This article will cover the most common time wasters encountered when working with Python and Big Data and provide suggestions to get back on track and spend time on what really matters: using creativity and scientific methods to generate insights from vast amounts and diverse types of data.
Let's compare a reasonable implementation in vanilla Python and an implementation using the powerful abstractions of Python Pandas: ###2.1 Vanilla Python ###2.2 Pandas Notes: Doing the task in vanilla Python does have the advantage of not needing to load the whole file in memory - however, pandas does things behind the scenes to optimize I/O and performance.
Slow programs also limit the amount of experimentation a developer can do - if your program takes ten minutes to output results for a small dataset, you have the possibility to tweak and execute your program only around thirty times per day.
After launching IPython, type: Subsequently, you get an output of this form which describes what percentage of execution time was spent on which line at the function: Using the line profiler has helped me personally identify bottlenecks with the use of the aforementioned Python Pandas library and achieve tenfold speedups by tweaking the implementation.
###3.1 Uncythonized version Paste this into IPython: ###3.2 Cythonized version Install cythonmagic if you don't have it already, and within IPython type: and copy-paste the following text as a single block: Then view the results: We achieve a speed-up of two orders of magnitude just by defining types.
The basic concept to understand is that Epoch time is the same number around the world at any given instant but how this number is translated into hours and minutes of the day depends on the timezone and the time of the year (because of daylight savings).
In the example below, we'd expect the time difference of the same date and time between UTC and the Amsterdam timezone to be one hour in winter, but, it's not: Ultimately, Python's native time support is at times counter intuitive and at times lacking.
Before a library of the caliber and adoption of JodaTime in Java is implemented in Python, developers are advised to tread very carefully, test extensively that time methods do what they think they do and generally check methods whether they return time in UTC or local machine time and opt for storing and using UTC for their transformations where possible.
It is not uncommon for developers to choose a faster framework to do the heavy lifting on the data (basic filtering and slicing) and then attack the resulting (smaller) dataset with Python to take advantage because Python is less restrictive when it comes to exploratory analysis.
The whole process may end up looking like this: Developer launches a Java Map/Reduce job on a dataset with orders to filter on orders of products of a certain brand, waits until it's done, then uses the command line to copy the results from HDFS to the local filesystem, and then launches a Python script on the data to find the most popular products and days.
By invoking the luigi scheduler with the name of the last task you want to run (in our example, the visualization of the most popular products), you can sit back and relax while the necessary tasks get launched one after the other (or in parallel, where possible) to produce your end result.
schemata When dealing with a variety of data sources, having the confidence that the data is valid and failing fast when it is not are two important prerequisites to maintaining the integrity of your analysis and to taking corrective measures in time.
##8 Mistake #7: No (regression) testing Testing data analysis pipelines is in some ways a bit trickier than general software testing, because sometimes it's exploratory in nature so there may be no 100% fixed "right"
Unit testing the functionality on a small dataset is useful but not enough - testing the application on real data of the correct size at regular intervals and especially when major changes are made is the only way to be reasonably sure that nothing broke.
When one observes that they're spending a disproportionate amount of time doing things that don't serve their end goals (for instance, loading CSV files or trying to use the datetime library without understanding it), it's time to take a step back, examine your processes and discover if there is a more leveraged way of doing things.
- On Friday, June 22, 2018
Import Data and Analyze with Python
Python programming language allows sophisticated data analysis and visualization. This tutorial is a basic step-by-step introduction on how to import a text file ...
The Best Way to Visualize a Dataset Easily
In this video, we'll visualize a dataset of body metrics collected by giving people a fitness tracking device. We'll go over the steps necessary to preprocess the ...
Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
In this Python Programming Tutorial, we will be learning how to work with csv files using the csv module. We will learn how to read, parse, and write to csv files.
How to Predict Stock Prices Easily - Intro to Deep Learning #7
We're going to predict the closing price of the S&P 500 using a special type of recurrent neural network called an LSTM network. I'll explain why we use ...
Panel Data Models with Individual and Time Fixed Effects
An introduction to basic panel data econometrics. Also watch my video on "Fixed Effects vs Random Effects". As always, I am using R for data analysis, which is ...
Genetic Algorithms - Learn Python for Data Science #6
In this video, we build a Gamma Radiation Classifier and use Genetic Programming to pick the best Machine Learning model + hyper-parameters FOR US in 40 ...
Predicting the Winning Team with Machine Learning
Can we predict the outcome of a football game given a dataset of past games? That's the question that we'll answer in this episode by using the scikit-learn ...
Train an Image Classifier with TensorFlow for Poets - Machine Learning Recipes #6
Monet or Picasso? In this episode, we'll train our own image classifier, using TensorFlow for Poets. Along the way, I'll introduce Deep Learning, and add context ...
TensorFlow in 5 Minutes (tutorial)
This video is all about building a handwritten digit image classifier in Python in under 40 lines of code (not including spaces and comments). We'll use the ...
Coding With Python :: Learn API Basics to Grab Data with Python
Coding With Python :: Learn API Basics to Grab Data with Python This is a basic introduction to using APIs. APIs are the "glue" that keep a lot of web applications ...