{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Diagnostic Generator" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This model is trained over around 2 millions diagnostics to extract the probability distributions of word bigrams, which are groups of 2 words that appear one after the other. There are more frequent bigrams than others, for example the bigram caries dentinaria is more frequent than caries gingival and using these conditional probabilities we can synthesize new diagnostics that appears to be written by humans. The method used to model this process is a First Order Hidden Markov Model." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import sys # Module to interact with the operating system.\n", "sys.path.append(\"..\") # Adds higher directory to python modules path.\n", "import src.utils # Loading utilities tu use the model." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "synthesizer = src.utils.DiagnosticGenerator( # Class to construct the Generator from a vocabulaty and a Markov matrix\n", " markov_matrix_file = r\"../models/model.npz\", # Location of a binary scipy sparse matrix containing the markov matrix.\n", " vocabulary_file = r\"../models/vocabulary.txt\" # Location of a text file containing each word of the vocabulary separated by a line break.\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['',\n", " 'tumor',\n", " 'de',\n", " 'la',\n", " 'agudeza',\n", " 'visual',\n", " 'no',\n", " 'insulinodependiente',\n", " '']" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "synthesizer.generate() # Method to generate a list of words based on the Markov model." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }