{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# HypTrails\n", "> This tutorial is still in development!" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "from scipy.sparse import csr_matrix\n", "from sklearn.preprocessing import normalize\n", "\n", "from pytrails.hyptrails import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-51.7608370813\n" ] } ], "source": [ "transition_counts = csr_matrix(\n", " [[1, 2, 3], \n", " [4, 5, 6], \n", " [7, 8, 9]],\n", " dtype=np.float64)\n", "transition_probabilities = normalize(transition_counts, \"l1\", axis=1)\n", "pseudo_counts = transition_probabilities * 5\n", "ml = MarkovChain.marginal_likelihood(transition_counts, pseudo_counts)\n", "print(ml)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 0 }