A Comprehensive Guide to Machine Learning

Chapters

Data scientists are exceptional people who bring data analysis to a new level. These analytical experts have a high level of technical skills and can solve the most complicated problems with a high level of inquisitiveness.

In simpler words, data scientists are those who structure and deploy the specific models which we’ve been discussing. In the previous discussions, we’ve talked about platforms, and those platforms are where data scientists deploy their specific models. However, they can also use other tools to analyze their data.

**Roles of a Data Scientist**

• Pinpoint which data-analytics problem would offer the most benefit to an organization.

• Identify the ideal variables and data sets.

• Gather multiple sets of unstructured and structured data out of disparate sources.

• Verify and clean data for increased accuracy, uniformity, and completeness.

• Come up with algorithms and models to hunt the stores of large data.

• Analyze data for pattern and trend identification.

• Interpret data to trace ideal solutions and opportunities.

• Share findings with stakeholders through the use of visualization models and other methods.

* From research conducted by Burtch Works* about data scientists, 88 percent of them have a master’s degree while 46 percent have doctoral degrees. Not surprisingly, most data scientists are highly educated people.

**Languages**

Given that the primary role of data scientists is to connect the world of IT to the world of mathematics, they need to understand how to deploy their code and how to use technology to deliver their analyses. The most common coding languages which data analysts use today are * R Code* and

**R vs. Python for Data Science**

Both R and Python have practical applications for data scientists. Below you’ll find some highlights of the comparisons between R and Python and when you may use each one.

**R** is useful when the data analysis you plan to do requires you to dig in for some preliminary data dives, and it’s useful for almost any type of data analysis you’d want to do because of the large number of packages and readily accessible tests that can provide you with the tools you need to get up and moving on your data analysis. R packages (see below) can further your reach with packages for data visualizations and Machine Larning.

**Python** is useful when you need to integrate your data analysis activities with web apps or if you need to incorporate some statistics codes into a production database arrangement. As a robust programming language on its own, Python makes for a practical way to put algorithms into place when you’re working with production applications.

In the past, Python packages for data analysis were in their infancy, but their growth and capabili- ties have increased over recent years. NumPy, SciPy and pandas for data manipulation (see more in Python libraries below) have made Python useful from a data analysis perspective. From an ML standpoint, scikit-learn is useful when you want to consider multiple versions of a single algorithm.

**Why Do Data Scientists Recommend Python?**

Among those high-level languages commonly used by data scientists, Python makes the claim that it’s easy to learn, friendly, fast, open, and powerful. Developed in the 1980s and named after the comedy group Monty Python, this platform has established its presence in the data science industry because of its number of libraries created using this language.

Additionally, Python also has a simple syntax which is easy to understand for coding newbies, one that is easily recognizable for anyone who has dealt with Java, Visual Basic, C/C++, and Matlab. Python prides itself on being a multipurpose, user-friendly programming language when dealing with quantitative and analytical computing.

Data scientists also find Python an easy language to use when developing visualizations that serve as an essential function to their work while relaying analysis to organizational stakeholders. This process gets carried out using APIs such as data visualization libraries and Plotly.

Another selling point of Python is that it scales quickly and gets equipped with handy tools such as * Jupyter Notebook*. This tool serves as an interactive computational setting where rich text, plots, rich media, mathematics, and code execution can be joined. You can also run a number of blocks and lines of code over various cells using this tool. Additionally, you can play with them, interchange their positions up or down, and have results display just below the cell. Lastly, writing R, Scale, SQL, and other languages in this tool is also possible which permits easier and more efficient workflow.

**Why Do Data Scientists Recommend R Code?**

R is another open-source coding language and platform setting developed for graphics and statistical computing. It is R Foundation for Statistical Computing supported.

Developed in the 1990s by Ross Ihaka along with Robert Gentleman from New Zealand’s University of Auckland, R served as statistical software for students. It was further improved through the decades through the everincreasing number of user-created libraries.

R Code can be used in many libraries and data scientists prefer it because of these other reasons:

• R serves as an object-oriented platform developed by statisticians. R creates objects, functions, and operators, all of which give users a convenient way to model, visualize, and explore data.

• Using R, standard statistical methods become easy to implement. Since most predictive and statistical modeling today is already done in R, most techniques get introduced first using R.

• R is free and comes with a high level of numerical accuracy and quality thanks to countless improvement efforts by developers through the years. Having the R open interface offers easy system and application integration.

The R environment provides the following:

• Efficient storage facility and data handling

• A selection of operators to make calculations on specific arrays within particular matrices

• A manageable set of tools used for data analysis

• Graphical models designed for data analysis

These reasons can support why R is an excellent choice among data scientists over other platforms such as Python. That is, R can offer a better ability to deploy, visualize, and develop models within one system.

Packages and libraries give data scientists the tools inside Python for faster scaling of visualizations and data analysis.

**Python Libraries**

In the Python Tutorial, Modules are defined as files composed of Python statements and definitions — the filename equipped with the suffix .py.

Packages offer a way to structure the Python’s module namespace by “dotted module names.”

“Library” is a term used for a number of codes applied for use in various applications. It delivers generic functionality for specific applications.

The moment a package or module gets published, those entities can be called by many as a library. For much of the time, a library can be composed of packages or a single package, but it can still be considered as a single module.

Among those Python libraries commonly used by data scientists are the following:

**Pandas**

One of the most commonly used libraries is * Pandas*. It is a one of the most preferred and widely used tools to open source data and implement manipulation. In order to use Pandas in your Jupyter Notebook, you need to first import the library. Importing a library means loading it into the memory for further using. In the Jupyter Notebook, all you have to do is running the following code:

**scikit-learn**

When it comes to machine learning, the * scikit-learn* library is the first step for most people. It includes various classification, regression and clustering algorithms, such as support vector machines, random forests, gradient boosting, and k-means. Simply running code below to import the scikit-learn library and machine learning models you want.

**NumPy**

* NumPy* is a foundational library used for particular computing within Python. This platform introduces models for multidimensional matrices and arrays. Additionally, routines enable developers to execute advanced statistical and mathematical functions using as little coding as possible.

**SciPy**

* SciPy* builds upon NumPy through accumulating algorithms along with high-level commands designed for visualizing and manipulating data. It also comes with functions designed for solving differential equations, computing integrals numerically, and many other functions.

**Matplotlib**

This platform is essential in a Python library when you’re developing 2D plots and graphs. Compared to the more advanced libraries, * Matplotlib* needs more commands to create better-looking graphs and figures.

**Theano**

* Theano* uses a NumPy-like syntax to optimize and evaluate mathematical expressions. It comes with an amazing speed that is highly essential for deep learning and complex computational tasks.

**TensorFlow**

Developed by Google, this platform is a high-profile entrant in the field of ML. * TensorFlow* became developed as a successor to the open-source platform DistBelief, a framework for modeling and training neural works.

**Scrapy**

* Scrapy *is designed for developing spider bots which crawl over the web and extract structured data such as contact info, prices, and URLs.

**NLTK**

This platform compiles several libraries designed for NLP, Natural Language Processing. * NLTK (Natural Language Toolkit)* enables easy entity identification, text tagging, and parse trees display. In addition, you can also do more complex tasks such as automatic summarization and sentiment analysis.

**Seaborn**

* Seaborn* is another common visualization library used by many data scientists. It builds over Matplotlib’s foundation and is an easier tool to use for generating various types of plots along the lines of violin plots, time series, and heat maps.

**Bokeh**

* This tool *permits zoomable and interactive plots over modern web browsers through JavaScript widgets. It also provides a three-level interface over high-level abstractions which enable you to generate complex plots quickly.

**Basemap**

* This tool* allows you to easily manipulate and transfer maps over to Matplotlib by taking Matplotlib’s coordinates and using them over 25 different projections.

**NetworkX**

* NetworkX* permits easy creation and analysis of graphs and networks. This platform works conve- niently on standard and non-standard data formats.

R Packages are a collection of R functions, compiled code, and data stored over a well-defined format. As soon as you install this tool, load it over to a session so that you can use it.

**Forecast**

If you need to consider time series, or a series of observations about well-defined data points obtained through repeated measurements over time, you’ll find the forecast package useful for time series analysis. This package can also help you when you need to predict the future value of a time series (for example, a future stock price).

**nnet**

This common platform is widely used because it is easy to understand. Unfortunately, nnet can also be a challenge to use since the platform gets limited only to one layer of nodes.

**klaR Visualization and Classification**

The CARET (Classification and Regression Training) module combines prediction and model training. This combination allows data scientists to run multiple algorithms for a specific business problem. Additionally, developers can investigate parameters for a specific algorithm through controlled experiments.

**plyr**

* This package* offering is like the salvation of a cool breeze on a sultry summer day. When you need to break up a big data structure into homogenous units, apply a function to each one of those pieces, and then bring all the results back together, plyr has the capability to fit the same model to each subset of a data frame, calculate summary statistics for each group, and then perform transformations that include scaling and standardizing.

**ggplot2**

Answering the pleas of those who work with graphics, * ggplot2* offers a powerful model of graphics creation that allows you to shape complex multi-layered graphics. This package operates on the idea that you can build graphs by using a data set, visual marks (called gemos) that represent data points, and a coordinate system. It also takes care of those details like creating legends for graphics.

**igraph**

* igraph* is a library collection for creating and manipulating graphs and analyzing networks. It is widely used in academic research, like generating graphs, computing centrality measures and path length based on properties.

**Random Forest**

As one of the widely used algorithms in the ML field, this platform can be used to develop multiple decision trees where you’ll input observations. When using this platform, data scientists must use numeric variables or factors. You’re allowed a maximum of 32 levels when using Random Forest.Forest.

**reshape2**

Shifting data between long and wide formats gets less complicated with * reshape2*. Using two functions, melt and cast, you can take wide-format data and render it as long-form data (melting) or take long-format data and present it as wide-format data (casting). With reshape2, the format your data takes follows from what you intend to do with your data. We’ve covered a plethora of the tools behind ML in this chapter. While these tools are sophisticated ones for marketers, we certainly want you to be aware that not everything in life is 100 percent fool-proof. In the next chapter, we’ll drill down into some cautionary tales about ML problems and how you can improve your success and accuracy with ML.