Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from tucker import Tucker\n",
"%matplotlib inline "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"\"\"\" Define model \"\"\"\n",
"model = Tucker(R=5,S=10,T=15,max_iter=5)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"\"\"\" Make test data \"\"\"\n",
"true_R = 5\n",
"true_S = 10\n",
"true_T = 15\n",
"true_U = np.random.normal(loc=0.0, scale=1, size=(10,true_R))\n",
"true_V = np.random.normal(loc=0.0, scale=1, size=(15,true_S))\n",
"true_W = np.random.normal(loc=0.0, scale=1, size=(20,true_T))\n",
"true_G = np.random.normal(loc=0.0, scale=1, size=(true_R, true_S, true_T))\n",
"X = {}\n",
"for i in range(true_U.shape[0]):\n",
" for j in range(true_V.shape[0]):\n",
" for k in range(true_W.shape[0]):\n",
" X[(i,j,k)]=0\n",
" for r in range(true_R):\n",
" for s in range(true_S):\n",
" for t in range(true_T):\n",
" X[(i,j,k)] += true_G[r,s,t]*true_U[i,r]*true_V[j,s]*true_W[k,t]\n",
" X[(i,j,k)] += np.random.normal(loc=0, scale=0.1)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<tucker.Tucker instance at 0x105efddd0>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(X)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEg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XdU3U3SV4FrgNdJ2lDuABzNvRn4c6q/WNeU6Z11D6qLzQK+L+lm\nqj8UV9pu++XK0br8HFBERNQun4wiIqJ2CaOIiKhdwigiImqXMIqIiNoljCIionYJo4iIqF3CKKJL\nSPqMpEMlHTPSLUcknSTp+DJ/gqRXdnaUEe2RMIroHgdR/djp24B/a9bB9gW2LyqLJwDjCiNJ0ycy\nwIh2SdFrRM0knQscCewD3Am8BrgLuMz2mcP6DgKPAXdT3f/pV8CTwCFU9836O+ClwIPACbY3Sroa\nWAP8EfBV4B5gKfAM8Fvbb23n8UW0In8lRdTM9qmSvk718z4fB662/eYx1rlM0keB/2r7J+VHU/8R\nWGz7N5L+FDgb+GBZ5YW25wNIugU40vavhn6vLaJuCaOI7vBGqk8vrwd+th3rvw7YH1hZ/YYq04CN\nDc9f0jD/I+BCSZcC+bXv6AoJo4gaSTqQ6nTbANWptRdXzVoDHGL7yVY3Bdxq+5ARnn98aMb2SZIO\norqL5w2S5tl+aHuPIWIy5AKGiBrZXlNu+PZzqu98vkd1Cu3AFoLoUWDnMn8HsJukQ6C615Gk/Zqt\nJOk1tq+1/UngN2x7362IWuSTUUTNJO0GbLa9VdLrbbd6mu5C4AJJQxcwHAucJ+llVP9v/wPQ7LYl\n50qaS/VpajVw00SPIWKicjVdRETULqfpIiKidgmjiIioXcIoIiJqlzCKiIjaJYwiIqJ2CaOIiKhd\nwigiImqXMIqIiNr9f0esJYhdz92gAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x109e40290>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(model._losses)\n",
"plt.ylabel('Loss')\n",
"plt.xlabel('# iters')\n",
"plt.title('Tucker')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0669052751507\n"
]
}
],
"source": [
"residual = 0\n",
"count = 0\n",
"for indices in X:\n",
" residual += abs(X[indices]-model.predict(indices))\n",
" count += 1\n",
"print residual/count"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment