{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\n# Aligning two matrices with the procrustes function\n\n\nIn this example, we load in some synthetic data, rotate it, and then use the\nprocustes function to get the datasets back in alignment.  The procrustes\nfunction uses linear transformations to project a source matrix into the\nspace of a target matrix.\n\n"
      ], 
      "cell_type": "markdown", 
      "metadata": {}
    }, 
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "# Code source: Andrew Heusser\n# License: MIT\n\n# import\nimport hypertools as hyp\nimport numpy as np\nimport scipy\n\n# load example data\ngeo = hyp.load('spiral')\ngeo.plot(title='Before Alignment')\n\n# use procrusted to align the data\nsource, target = geo.get_data()\naligned = [hyp.tools.procrustes(source, target), target]\n\n# after alignment\nhyp.plot(aligned, ['-','--'], title='After alignment')"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }
  ], 
  "metadata": {
    "kernelspec": {
      "display_name": "Python 2", 
      "name": "python2", 
      "language": "python"
    }, 
    "language_info": {
      "mimetype": "text/x-python", 
      "nbconvert_exporter": "python", 
      "name": "python", 
      "file_extension": ".py", 
      "version": "2.7.11", 
      "pygments_lexer": "ipython2", 
      "codemirror_mode": {
        "version": 2, 
        "name": "ipython"
      }
    }
  }
}