About this Tutorial
This tutorial assumes you have no programming experience and do not have a development environment. It will guide you through setting up a development environment and producing the code to access advanced machine learning solutions.
If you run into any issues while following this tutorial, please feel free to create an issue on this repository or contact us at contact@indico.io
Code Editor
You will probably need some kind of text editor for your code. Unless you have a preference already, I recommend Atom.
Table of Contents
Getting Started: Development Environment
Using Indico
Getting Started: Development Environment
Ubuntu / Linux
- Open the Terminal application (CTRL + ALT + T) or (Super Key & search “Terminal”) and update your package manager package lists.
- Install Python 2.7.
- Install
pip
, a Python package manager. - Install the Python developer library.
- Install the imaging dependencies.
For Ubuntu 12.04 LTS or Raspian Wheezy 7.0sudo apt-get install -y libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
For Ubuntu 14.04
- Install the
indicoio
Python package.
sudo apt-get update
sudo apt-get install -y python
sudo apt-get install -y python-pip
sudo apt-get install -y build-essential python-dev
sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
sudo pip install indicoio
indicoio
should be successfully installed! Now you’re ready for the next step.
OSX
- Open up a Terminal – go to Spotlight (CMD + SPACE) and search “Terminal”.
- Make sure you have XCode and its developers tools installed.
- Install Homebrew (a great package manager for OSX).
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Add Homebrew’s path to the start of your existing
$PATH
variable.open ~/.profile
Then, add the following to the bottom of the file.
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Now, reload the profile.
- Make sure you have Python2.7 installed.
python --version # should respond with Python 2.7.x
If you don’t have Python installed:
- Install the appropriate imaging libraries.
- Install the
indicoio
Python package.
xcode-select --install
source ~/.profile
brew update brew doctor brew install python
brew install libjpeg brew install zlib
sudo pip install indicoio
indicoio
should be successfully installed! Now you’re ready for the next step.
Windows
Setting up Windows is going to be a little bit involved, so if you have a choice, I highly recommend using either OSX or Linux instead.
For development in Windows, I recommend getting Cygwin, which gives Windows some commands commonly found in Linux / OSX environments.
- Download Cygwin and run the downloaded installer (64 bit or 32 bit depending). Go ahead and choose all the default options. When it asks to choose a mirror, choose whichever one you’d like – it doesn’t matter.
- Add the Cygwin path to your environment variables. See these instructions. For Windows 8 and 10, you can access environment variables by searching “Environment Variables” in your Start menu.
- Find the PATH variable under your System Environment Variables. Make sure there is a semicolon at the end “;” or add one if there isn’t. Then, paste
C:cygwin64bin
at the end (ensure that folder exists). LEAVE THIS WINDOW OPEN. We’ll be making more changes. - Download the latest version of Python 2 (first link). Choose the Windows x86(-64) MSI installer (again 64 bit or regular).
- After you’ve run the Python Installer, go add to the PATH variable again:
C:Python27
ANDC:Python27Scripts
. - Now, open a Command Prompt. (Start Menu + “cmd”). If you are on an older version of Windows, you may have to do Start -> Run -> “cmd”.
- Test the commands to make sure everything was installed and setup properly.
- In the Command Prompt still:
ls python pip
If ls
fails, Cygwin was not installed and setup properly.
If python
fails, Python was not installed and setup properly.
If pip
fails, C:Python27Scripts
either does not exist or was not added properly.
pip install indicoio
indicoio
should be successfully installed! Now you’re ready for the next step.
Using indico
Pull up your favorite code editor (Atom. is the one recommended at the top of this tutorial).
- Create a new file and save it as
trying-indico.py
- Add the following line to the top of this file:
- Get your indico API key by signing up for indico. You get a good number of free calls per month to test as much as you need. You’ll find your API key at the top of your dashboard once you log in.
- Add it to the script!
- There are a bunch of APIs available – visit our docs to get set up with one (or a few!) of them. Switch the code snippets to
python
.
import indicoio
This imports the indicoio
package that contains several functions that will help you access the Machine Learning APIs that indico provides.
indicoio.config.api_key = "Paste your API Key here, inside the quotation marks"
Now you’re ready to see some Machine Learning action! 😉
You can check out all the different kinds of APIs indico provides and learn more about what they do.
Sentiment HQ Example
Here’s an example of how to make a call to our Sentiment HQ API.
import indicoio indicoio.config.api_key="Your API key here" sentiment = indicoio.sentiment_hq("Meditating on happiness makes me very happy.") print sentiment
To run this script, pull up your terminal (or command prompt) and navigate to the folder that you saved this script by using ls
to list the contents of the current folder and cd
to change to the folder you want. Then, run the command python
followed by the filename.
$ python trying-indico.py 0.994322896004
The sentiment of “Meditating on happiness makes me very happy” is 0.994. The closer the value is to 1
the more positve sentiment it is. Likewise, the closer to 0
the more negative the sentiment is. Looking good!
Try using an article URL!
import indicoio indicoio.config.api_key="Your API key here" sentiment = indicoio.sentiment_hq("http://www.vanityfair.com/news/2015/10/the-serious-problem-with-treating-donald-trump-seriously", url=True) print "Sentiment of the article is: {0}".format(sentiment) # Let's get some keywords too! (This is a comment by the way. Comments aren't run as code, but just act as notes from one programmer to another.) keywords = indicoio.keywords("http://www.vanityfair.com/news/2015/10/the-serious-problem-with-treating-donald-trump-seriously", url=True, top_n=5) print "Top 5 keywords of the article are:n{0}".format(keywords)
Now that you’re all set up, why not try building an app with one of our APIs? Check out these tutorials:
Foundations for Building a Flask + indico Web App
Make Content Recommendations Better With Machine Learning
Going from Tweets to Trends in Minutes
Stock Image Similarity with Image Features (or How a Program is More Fashionable than Me)
Feel free to reach out to us with questions, or feedback as to how we can improve our tutorials to help you build with indico at contact@indico.io.