### What’s Blockspring?

Blockspring is a really exciting, YC backed startup, who pitch themselves as “The world’s library of functions, accessible from everywhere you do work.” Their platform allows you to interact with a library of various APIs through a spreadsheet, simple code snippets and soon a chat interface.

The platform lets you run 1000+ functions directly from your spreadsheet or through simple code snippets for the more technically inclined. Accessing APIs with Blockspring is done through the concept of functions and they certainly have some cool APIs available to interact with in their library.

Where Blockspring gets really interesting though, is when you start to combine multiple functions. Your spreadsheet pretty much becomes a playpen where you can interact with one or multiple APIs and create powerful applications and “mashups”. Some of the examples of what can be done with Blockspring include, automating social activity and monitoring, gathering marketing data about user segments and usage, accessing public datasets, scraping websites and now even analyzing text and unstructured data all of which are really nicely showcased on their getting started page.

### AYLIEN and Blockspring

Like Blockspring, we want to get the power of our API into the hands of anyone that can get value from it. We launched our own Text Analysis Add-on for google sheets last year. The add-on works in the same way as Blockspring, through simple functions and acts as an interface for our Text Analysis API. Integrating with Blockspring, however, means our users can now open up their use cases by combining our functions with other complementary APIs to create powerful tools and integrations.

All of the AYLIEN end-points are available through Blockspring as simple snippets or spreadsheet functions and getting started with AYLIEN and Blockspring is really easy.

#### It’s simple to get up and running:

Step 1.

Step 2.

Grab your AYLIEN APP ID and API key and keep it handy. If you don’t have an AYLIEN account just sign up here.

Step 3.

Explore the getting started section to see examples of the functions and APIs available.

Step 4.

Try some of the different functions through their interactive docs to get a feel for how they work.

Step 5.

Go wild and start building and creating mashups of functions with code snippets or in Google Sheets.

PS: Don’t forget to add your AYLIEN keys to your Blockspring account in the Secrets section of your account settings. Once they’ve been added, you won’t have to do it again.

We’re really excited to see what the Blockspring community start to build with our various functions. Over the next couple of weeks, we’ll also be showcasing some cool mashups that we’ve put together in Blockspring so keep your eyes peeled on the blog.

###### General

If you’re relatively new to Machine Learning and it’s applications, you’ll more than likely have come across some pretty technical terms that are often difficult for the novice mathematician/scientist to get their head around.

Following on from a previous blog, (10 Common NLP Terms Explained for the Text Analysis Novice), we decided to put together a list of 10 Machine Learning terms which have been broken down in simple English, making them easier to understand. So, if you’re struggling to understand the difference between Supervised and Un-supervised Learning you’ll enjoy this post.

#### Machine Learning

A subfield of computer science and artificial intelligence (AI) that focuses on the design of systems that can learn from and make decisions and predictions based on data. Machine learning enables computers to act and make data-driven decisions rather than being explicitly programmed to carry out a certain task. Machine Learning programs are also designed to learn and improve over time when exposed to new data. Machine learning has been at the center of many technological advancements in recent years such as self-driving cars, computer vision and speech recognition systems.

#### Supervised Learning

Where a program is “trained” on a pre-defined dataset. Based off its training data the program can make accurate decisions when given new data. Example: Using a training set of human tagged positive, negative and neutral tweets to train a sentiment analysis classifier.

#### Unsupervised Learning

Where a program, given a dataset, can automatically find patterns and relationships in that dataset. Example: Analyzing a dataset of emails and automatically grouping related emails by topic with no prior knowledge or training which is also known as the practice of clustering.

#### Classification

A sub-category of Supervised Learning, Classification is the process of taking some sort of input and assigning a label to it. Classification systems are usually used when predictions are of a discrete, or “yes or no” nature. Example: Mapping a picture of someone to a male or female classification.

#### Regression

Another sub-category of supervised learning used when the value being predicted differs to a “yes or no” label as it falls somewhere on a continuous spectrum. Regression systems could be used, for example, to answer questions of “How much?” or “How many?”.

#### Decision Trees

A decision tree is a decision support tool that uses a tree-like graph or model of decisions and their possible consequences. A decision tree is also a way of visually representing an algorithm.

Example:

A decision tree showing survival of passengers on the Titanic (“sibsp” is the number of spouses or siblings aboard). Source: http://en.wikipedia.org/wiki/Decision_tree_learning

#### Generative Model

In probability and statistics, a Generative Model is a model used to generate data values when some parameters are hidden. Generative models are used in Machine Learning for either modeling data directly or as an intermediate step to forming a conditional probability density function. In other terms you model p(x,y) in order to make predictions (which can be converted to p(x|y) by applying the Bayes rule) as well as to be able to generate likely (x,y) pairs, which is widely used in Unsupervised Learning. Examples of Generative Models include Naive Bayes, Latent Dirichlet Allocation and Gaussian Mixture Model.

#### Discriminative Model

Discriminative Models or conditional models, are a class of models used in Machine Learning to model the dependence of a variable y on a variable x. As these models try to calculate conditional probabilities, i.e. p(y|x) they are often used in Supervised Learning. Examples include Logistic Regression, SVMs and Neural Networks.

#### Deep Learning

Quite a “hot topic” in recent years, deep learning refers to a category of machine learning algorithms that often use Artificial Neural Networks to generate models. Deep Learning techniques, for example, have been very successful in solving Image Recognition problems due to their ability to pick the best features, as well as to express layers of representation.

#### Neural Networks or Artificial Neural Networks

A simple Neural Network. Source: http://en.wikipedia.org/wiki/Artificial_neural_network

Inspired by biological neural networks, artificial neural networks are a network of interconnected nodes that make up a model. They can be defined as statistical learning models that are used to estimate or approximate functions that depend on a large number of inputs. Neural networks are usually used when the volume of inputs is far too large for standard machine learning approaches previously discussed.

Keep an eye out for more in the series and check out our Text Analysis 101 Series for detailed explanations of Text Analysis techniques.

Commonly used in Machine Learning, Naive Bayes is a collection of classification algorithms based on Bayes Theorem. It is not a single algorithm but a family of algorithms that all share a common principle, that every feature being classified is independent of the value of any other feature. So for example, a fruit may be considered to be an apple if it is red, round, and about 3″ in diameter. A Naive Bayes classifier considers each of these “features” (red, round, 3” in diameter) to contribute independently to the probability that the fruit is an apple, regardless of any correlations between features. Features, however, aren’t always independent which is often seen as a shortcoming of the Naive Bayes algorithm and this is why it’s labeled “naive”.

Although it’s a relatively simple idea, Naive Bayes can often outperform other more sophisticated algorithms and is extremely useful in common applications like spam detection and document classification.

In a nutshell, the algorithm allows us to predict a class, given a set of features using probability. So in another fruit example, we could predict whether a fruit is an apple, orange or banana (class) based on its colour, shape etc (features).

### Pros and cons of Naive Bayes:

• It’s relatively simple to understand and build
• It’s easily trained, even with a small dataset
• It’s fast!
• It’s not sensitive to irrelevant features

• It assumes every feature is independent, which isn’t always the case

### Explanation:

A simple example best explains the application of Naive Bayes for classification. When writing this blog I came across many examples of Naive Bayes in action. Some were too complicated, some dealt with more than Naive Bayes and used other related algorithms, but we found a really simple example on StackOverflow which we’ll run through in this blog. It explains the concept really well and runs through the simple maths behind it without getting too technical.

So, let’s say we have data on 1000 pieces of fruit. The fruit being a Banana, Orange or some Other fruit and imagine we know 3 features of each fruit, whether it’s long or not, sweet or not and yellow or not, as displayed in the table below:

So from the table what do we already know?

• 50% of the fruits are bananas
• 30% are oranges
• 20% are other fruits

Based on our training set we can also say the following:

• From 500 bananas 400 (0.8) are Long, 350 (0.7) are Sweet and 450 (0.9) are Yellow
• Out of 300 oranges 0 are Long, 150 (0.5) are Sweet and 300 (1) are Yellow
• From the remaining 200 fruits, 100 (0.5) are Long, 150 (0.75) are Sweet and 50 (0.25) are Yellow

Which should provide enough evidence to predict the class of another fruit as it’s introduced.

So let’s say we’re given the features of a piece of fruit and we need to predict the class. If we’re told that the additional fruit is Long, Sweet and Yellow, we can classify it using the following formula and subbing in the values for each outcome, whether it’s a Banana, an Orange or Other Fruit. The one with the highest probability (score) being the winner.

#### Banana:

$\ P(Banana|Long,Sweet,Yellow) = frac{P(Long|Banana) cdot P(Sweet|Banana) cdot P(Yellow|Banana) cdot P(Banana)}{ P(Long) cdot P(Sweet) cdot P(Yellow)}$

$\ = frac{0.8 times 0.7 times 0.9 times 0.5}{P(evidence)}$

$\ = frac{0.252}{P(evidence)}$

#### Orange:

$\ P(Orange|Long,Sweet,Yellow) = 0$

#### Other Fruit:

$\ P(Other|Long,Sweet,Yellow) = frac{P(Long|Other) cdot P(Sweet|Other) cdot P(Yellow|Other) cdot P(Other)}{ P(Long) cdot P(Sweet) cdot P(Yellow)}$

$\ = frac{0.5 times 0.75 times 0.25 times 0.2}{P(evidence)}$

$\ = frac{0.01875}{P(evidence)}$

In this case, based on the higher score (0.01875 lt 0.252) we can assume this Long, Sweet and Yellow fruit is, in fact, a Banana.

Now that we’ve seen a basic example of Naive Bayes in action, you can easily see how it can be applied to Text Classification problems such as spam detection, sentiment analysis and categorization. By looking at documents as a set of words, which would represent features, and labels (e.g. “spam” and “ham” in case of spam detection) as classes we can start to classify documents and text automatically. You can read more about Text Classification in our Text Analysis 101 Series.

There you have it, a simple explanation of Naive Bayes along with an example. We hope this helps you get your head around this simple but common classifying method.