From 9f93f3c3f39b1fccbb2b77ba3b4a18c17703a586 Mon Sep 17 00:00:00 2001 From: Jun Matsushita Date: Fri, 23 Dec 2022 15:02:31 +0100 Subject: [PATCH] Add back output cells together with DB instructions --- examples/company_demo/concise_demo_ACT.ipynb | 67 ++++++++-- examples/ml_workflow_demo/ml_demo.ipynb | 121 ++++++++++++++++--- 2 files changed, 166 insertions(+), 22 deletions(-) diff --git a/examples/company_demo/concise_demo_ACT.ipynb b/examples/company_demo/concise_demo_ACT.ipynb index f2d3eca..1e54aad 100644 --- a/examples/company_demo/concise_demo_ACT.ipynb +++ b/examples/company_demo/concise_demo_ACT.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -50,9 +50,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CREATE TABLE get_manager (Person1 int, Person2 int);\n", + "CREATE TABLE get_name (Person1 int, Name2 text);\n", + "CREATE TABLE get_employees (Person1 int, ID2 int);\n", + "CREATE TABLE get_salary (Person1 int, Salary2 real);" + ] + } + ], "source": [ "print(generate_schema_sql(schema));" ] @@ -67,9 +78,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SELECT t1.Name2 AS emp_name, t2.Salary2 AS salary\n", + "FROM get_name AS t1, get_salary AS t2\n", + "WHERE t2.Person1=t1.Person1 AND t2.Salary2<=$2 AND t2.Salary2>=$1" + ] + }, + { + "data": { + "image/svg+xml": "\n\n\n\n\n\nG\n\n\n\nn1\n\nget_name\n\n\n\n\nn7\n\np\n\n\n\nn1--n7\n\n\n\n\n\nn8\n\nemp_name\n\n\n\nn1--n8\n\n\n\n\nn2\n\nget_salary\n\n\n\nn2--n7\n\n\n\n\n\nn9\n\nsalary\n\n\n\nn2--n9\n\n\n\n\nn3\n\n<=\n\n\n\nn3--n9\n\n\n\n\n\nn11\n\n_salupper\n\n\n\nn3--n11\n\n\n\n\nn4\n\n>=\n\n\n\nn4--n9\n\n\n\n\n\nn10\n\n_sallower\n\n\n\nn4--n10\n\n\n\n\n\nn5--n8\n\n\n\n\n\nn6--n9\n\n\n\n\n", + "text/plain": [ + "Catlab.Graphics.Graphviz.Graph(\"G\", false, \"neato\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"n1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box1\", :label => \"get_name\")), Catlab.Graphics.Graphviz.Node(\"n2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box2\", :label => \"get_salary\")), Catlab.Graphics.Graphviz.Node(\"n3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box3\", :label => \"<=\")), Catlab.Graphics.Graphviz.Node(\"n4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box4\", :label => \">=\")), Catlab.Graphics.Graphviz.Node(\"n5\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer1\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n6\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer2\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n7\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction1\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"p\")), Catlab.Graphics.Graphviz.Node(\"n8\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction2\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"emp_name\")), Catlab.Graphics.Graphviz.Node(\"n9\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction3\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"salary\")), Catlab.Graphics.Graphviz.Node(\"n10\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction4\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"_sallower\")) … Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n7\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n7\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n8\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n5\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n8\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n6\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n10\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n11\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}())], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :shape => \"ellipse\", :margin => \"0.05,0.025\", :width => \"0.5\", :height => \"0.5\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :len => \"0.5\"))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# We generate a query that gets all employees make a salary within some range\n", "q1 = @query schema (emp_name, salary) where \n", @@ -90,9 +121,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SELECT t1.Name2 AS emp_name, t2.Name2 AS man_name, t4.Salary2 AS salary\n", + "FROM get_name AS t1, get_name AS t2, get_manager AS t3, get_salary AS t4\n", + "WHERE t3.Person1=t1.Person1 AND t3.Person2=t2.Person1 AND t4.Person1=t2.Person1 AND t4.Salary2<=$2 AND t4.Salary2>=$1" + ] + }, + { + "data": { + "image/svg+xml": "\n\n\n\n\n\nG\n\n\n\nn1\n\nget_name\n\n\n\n\nn10\n\np\n\n\n\nn1--n10\n\n\n\n\n\nn12\n\nemp_name\n\n\n\nn1--n12\n\n\n\n\nn2\n\nget_name\n\n\n\n\nn11\n\nm\n\n\n\nn2--n11\n\n\n\n\n\nn13\n\nman_name\n\n\n\nn2--n13\n\n\n\n\nn3\n\nget_manager\n\n\n\nn3--n10\n\n\n\n\nn3--n11\n\n\n\n\nn4\n\nget_salary\n\n\n\nn4--n11\n\n\n\n\n\nn14\n\nsalary\n\n\n\nn4--n14\n\n\n\n\nn5\n\n<=\n\n\n\nn5--n14\n\n\n\n\n\nn16\n\n_supper\n\n\n\nn5--n16\n\n\n\n\nn6\n\n>=\n\n\n\nn6--n14\n\n\n\n\n\nn15\n\n_slower\n\n\n\nn6--n15\n\n\n\n\n\nn7--n12\n\n\n\n\n\nn8--n13\n\n\n\n\n\nn9--n14\n\n\n\n\n", + "text/plain": [ + "Catlab.Graphics.Graphviz.Graph(\"G\", false, \"neato\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"n1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box1\", :label => \"get_name\")), Catlab.Graphics.Graphviz.Node(\"n2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box2\", :label => \"get_name\")), Catlab.Graphics.Graphviz.Node(\"n3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box3\", :label => \"get_manager\")), Catlab.Graphics.Graphviz.Node(\"n4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box4\", :label => \"get_salary\")), Catlab.Graphics.Graphviz.Node(\"n5\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box5\", :label => \"<=\")), Catlab.Graphics.Graphviz.Node(\"n6\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box6\", :label => \">=\")), Catlab.Graphics.Graphviz.Node(\"n7\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer1\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n8\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer2\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n9\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer3\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n10\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction1\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"p\")) … Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n12\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n7\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n12\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n13\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n8\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n13\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n5\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n6\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n6\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n15\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n5\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n16\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}())], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :shape => \"ellipse\", :margin => \"0.05,0.025\", :width => \"0.5\", :height => \"0.5\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :len => \"0.5\"))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# We generate a second query that gets all employees whose managers make a salary within some range\n", "q2 = @query schema (emp_name, man_name,salary) where \n", diff --git a/examples/ml_workflow_demo/ml_demo.ipynb b/examples/ml_workflow_demo/ml_demo.ipynb index a964e8a..c98d0c8 100644 --- a/examples/ml_workflow_demo/ml_demo.ipynb +++ b/examples/ml_workflow_demo/ml_demo.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -32,9 +32,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\nG\n\n\n\ns1\n\nFiles\n\n\n\nt2\n\nextract\n\n\n\ns1->t2\n\n\n1\n\n\n\ns2\n\nImages\n\n\n\nt1\n\nevaluate\n\n\n\ns2->t1\n\n\n1\n\n\n\nt3\n\nsplit\n\n\n\ns2->t3\n\n\n1\n\n\n\nt4\n\ntrain\n\n\n\ns2->t4\n\n\n1\n\n\n\ns3\n\nNeuralNet\n\n\n\ns3->t1\n\n\n1\n\n\n\ns3->t4\n\n\n1\n\n\n\ns4\n\nAccuracy\n\n\n\ns5\n\nMetadata\n\n\n\nt1->s4\n\n\n1\n\n\n\nt1->s5\n\n\n1\n\n\n\nt2->s2\n\n\n1\n\n\n\nt3->s2\n\n\n2\n\n\n\nt4->s3\n\n\n1\n\n\n\nt4->s5\n\n\n1\n\n\n\n", + "text/plain": [ + "Catlab.Graphics.Graphviz.Graph(\"G\", true, \"dot\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"s1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"Files\", :shape => \"circle\", :color => \"#6C9AC3\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"s2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"Images\", :shape => \"circle\", :color => \"#6C9AC3\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"s3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"NeuralNet\", :shape => \"circle\", :color => \"#6C9AC3\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"s4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"Accuracy\", :shape => \"circle\", :color => \"#6C9AC3\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"s5\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"Metadata\", :shape => \"circle\", :color => \"#6C9AC3\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"t1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"evaluate\", :shape => \"square\", :color => \"#E28F41\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"t2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"extract\", :shape => \"square\", :color => \"#E28F41\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"t3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"split\", :shape => \"square\", :color => \"#E28F41\", :pos => \"\")), Catlab.Graphics.Graphviz.Node(\"t4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"train\", :shape => \"square\", :color => \"#E28F41\", :pos => \"\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t3\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")) … Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"t4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"s3\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"t1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"s4\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t2\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t1\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t4\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t4\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"t3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"s2\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"2\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"t2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"s2\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"t1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"s5\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"s2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"t1\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:labelfontsize => \"6\", :label => \"1\"))], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:rankdir => \"LR\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"plain\", :style => \"filled\", :color => \"white\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:splines => \"splines\"))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Initialize presentation object\n", "present = Presentation()\n", @@ -59,9 +70,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CREATE TABLE evaluate (NeuralNet1 text, Images2 text, Accuracy3 real, Metadata4 text);\n", + "CREATE TABLE extract (Files1 text, Images2 text);\n", + "CREATE TABLE split (Images1 text, Images2 text, Images3 text);\n", + "CREATE TABLE train (NeuralNet1 text, Images2 text, NeuralNet3 text, Metadata4 text);" + ] + } + ], "source": [ "print(generate_schema_sql(TrainDB()))" ] @@ -76,9 +98,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\nG\n\n\n\n\n\n\n\nn3\n\ntrain\n\n\n\n\nn0in1:e->n3:w\n\n\n\n\n\n\nn1\n\nextract\n\n\n\n\nn0in2:e->n1:w\n\n\n\n\n\n\n\nn2\n\nsplit\n\n\n\n\nn1:e->n2:w\n\n\n\n\n\n\nn2:e->n3:w\n\n\n\n\n\n\nn4\n\nevaluate\n\n\n\n\nn2:e->n4:w\n\n\n\n\n\n\nn3:e->n4:w\n\n\n\n\n\n\nn4:e->n0out1:w\n\n\n\n\n\n", + "text/plain": [ + "Catlab.Graphics.Graphviz.Graph(\"G\", true, \"dot\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Subgraph(\"\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"n0in1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"in1\")), Catlab.Graphics.Graphviz.Node(\"n0in2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"in2\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n0in1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n0in2\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}())], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:rank => \"source\", :rankdir => \"TB\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:style => \"invis\", :shape => \"none\", :label => \"\", :width => \"0\", :height => \"0.333\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:style => \"invis\")), Catlab.Graphics.Graphviz.Subgraph(\"\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"n0out1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"out1\"))], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:rank => \"sink\", :rankdir => \"TB\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:style => \"invis\", :shape => \"none\", :label => \"\", :width => \"0\", :height => \"0.333\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:style => \"invis\")), Catlab.Graphics.Graphviz.Node(\"n1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:color => \"black\", :comment => \"extract\", :fillcolor => \"white\", :id => \"n1\", :label => Catlab.Graphics.Graphviz.Html(\"\\n\\n\\n\\n\\n\\n
extract
\"), :style => \"solid\")), Catlab.Graphics.Graphviz.Node(\"n2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:color => \"black\", :comment => \"split\", :fillcolor => \"white\", :id => \"n2\", :label => Catlab.Graphics.Graphviz.Html(\"\\n\\n\\n\\n\\n\\n
split
\"), :style => \"solid\")), Catlab.Graphics.Graphviz.Node(\"n3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:color => \"black\", :comment => \"train\", :fillcolor => \"white\", :id => \"n3\", :label => Catlab.Graphics.Graphviz.Html(\"\\n\\n\\n\\n\\n\\n
train
\"), :style => \"solid\")), Catlab.Graphics.Graphviz.Node(\"n4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:color => \"black\", :comment => \"evaluate\", :fillcolor => \"white\", :id => \"n4\", :label => Catlab.Graphics.Graphviz.Html(\"\\n\\n\\n\\n\\n\\n
evaluate
\"), :style => \"solid\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n0in2\", \"e\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n1\", \"in1\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Files\", :id => \"e1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n0in1\", \"e\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n3\", \"in1\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"NeuralNet\", :id => \"e2\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n2\", \"in1\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Images\", :id => \"e3\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n3\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n4\", \"in1\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"NeuralNet\", :id => \"e4\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n3\", \"in2\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Images\", :id => \"e5\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"out2\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n4\", \"in2\", \"w\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Images\", :id => \"e6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n0out1\", \"w\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Accuracy\", :id => \"e7\"))], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :rankdir => \"LR\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :shape => \"none\", :width => \"0\", :height => \"0\", :margin => \"0\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:arrowsize => \"0.5\", :fontname => \"Serif\"))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "p = @program present (nn::NeuralNet, file::Files) begin\n", " images = extract(file)\n", @@ -138,9 +171,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SELECT t1.Images2 AS im_train, t1.NeuralNet1 AS nn, t2.Images2 AS im_test, t2.Accuracy3 AS acc, t2.Metadata4 AS md2\n", + "FROM train AS t1, evaluate AS t2, split AS t3\n", + "WHERE t2.NeuralNet1=t1.NeuralNet3 AND t3.Images2=t1.Images2 AND t3.Images3=t2.Images2 AND t2.Accuracy3>=$1" + ] + }, + { + "data": { + "image/svg+xml": "\n\n\n\n\n\nG\n\n\n\nn1\n\ntrain\n\n\n\n\nn10\n\nim_train\n\n\n\nn1--n10\n\n\n\n\n\nn12\n\nnn\n\n\n\nn1--n12\n\n\n\n\n\nn13\n\nnn_trained\n\n\n\nn1--n13\n\n\n\n\n\nn15\n\nmd\n\n\n\nn1--n15\n\n\n\n\nn2\n\nevaluate\n\n\n\n\nn11\n\nim_test\n\n\n\nn2--n11\n\n\n\n\nn2--n13\n\n\n\n\n\nn14\n\nacc\n\n\n\nn2--n14\n\n\n\n\n\nn16\n\nmd2\n\n\n\nn2--n16\n\n\n\n\nn3\n\nsplit\n\n\n\nn3--n10\n\n\n\n\nn3--n11\n\n\n\n\n\nn18\n\nim\n\n\n\nn3--n18\n\n\n\n\nn4\n\n>=\n\n\n\nn4--n14\n\n\n\n\n\nn17\n\n_base_acc\n\n\n\nn4--n17\n\n\n\n\n\nn5--n10\n\n\n\n\n\nn6--n12\n\n\n\n\n\nn7--n11\n\n\n\n\n\nn8--n14\n\n\n\n\n\nn9--n16\n\n\n\n\n", + "text/plain": [ + "Catlab.Graphics.Graphviz.Graph(\"G\", false, \"neato\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"n1\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box1\", :label => \"train\")), Catlab.Graphics.Graphviz.Node(\"n2\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box2\", :label => \"evaluate\")), Catlab.Graphics.Graphviz.Node(\"n3\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box3\", :label => \"split\")), Catlab.Graphics.Graphviz.Node(\"n4\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"box4\", :label => \">=\")), Catlab.Graphics.Graphviz.Node(\"n5\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer1\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n6\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer2\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n7\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer3\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n8\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer4\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n9\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:height => \"0\", :id => \"outer5\", :label => \"\", :margin => \"0\", :shape => \"none\", :style => \"invis\", :width => \"0\")), Catlab.Graphics.Graphviz.Node(\"n10\", OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"junction\", :fillcolor => \"black\", :height => \"0.075\", :id => \"junction1\", :label => \"\", :shape => \"circle\", :style => \"filled\", :width => \"0.075\", :xlabel => \"im_train\")) … Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n13\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n13\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n8\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n14\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n15\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n16\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n9\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n16\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n17\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}()), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n3\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n18\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}())], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :shape => \"ellipse\", :margin => \"0.05,0.025\", :width => \"0.5\", :height => \"0.5\"), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:fontname => \"Serif\", :len => \"0.5\"))" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "q = @query TrainDB() (im_train, nn, im_test, acc, md2) where (im_train, im_test, nn,\n", " nn_trained, acc, md,\n", @@ -155,16 +208,28 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Querying a PostgreSQL database\n", - "AlgebraicRelations also provides an interface with `LibPQ.jl` which allows us to query a database directly using the query object. Below is an example of the use of this interface." + "AlgebraicRelations also provides an interface with `LibPQ.jl` which allows us to query a database directly using the query object. Below is an example of the use of this interface.\n", + "\n", + "For this to work make sure you have a Postgres instance running with a `test_wf` database (running `createdb test_wf`) and with the following dataset\n", + "```sql\n", + "DELETE FROM train; DELETE FROM evaluate; DELETE FROM split; \n", + "INSERT INTO train VALUES ('nn_struc/struct1', 'im_tr_1', 'nn_struc/struct1'); \n", + "INSERT INTO evaluate VALUES ('nn_struc/struct1', 'im_te_1', 0.9, 'md_ev_3'); \n", + "INSERT INTO split VALUES ('im_1', 'im_tr_1', 'im_te_1');\n", + "INSERT INTO train VALUES ('nn_struc/struct2', 'im_tr_2', 'nn_struc/struct2'); \n", + "INSERT INTO evaluate VALUES ('nn_struc/struct2', 'im_te_2', 0.8, 'md_ev_5'); \n", + "INSERT INTO split VALUES ('im_2', 'im_tr_2', 'im_te_2');\n", + "```" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -173,7 +238,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -182,9 +247,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
2×5 DataFrame
Rowim_trainnnim_testaccmd2
String?String?String?Float32?String?
1im_tr_1nn_struc/struct1im_te_10.9md_ev_3
2im_tr_2nn_struc/struct2im_te_20.8md_ev_5
" + ], + "text/latex": [ + "\\begin{tabular}{r|ccccc}\n", + "\t& im\\_train & nn & im\\_test & acc & md2\\\\\n", + "\t\\hline\n", + "\t& String? & String? & String? & Float32? & String?\\\\\n", + "\t\\hline\n", + "\t1 & im\\_tr\\_1 & nn\\_struc/struct1 & im\\_te\\_1 & 0.9 & md\\_ev\\_3 \\\\\n", + "\t2 & im\\_tr\\_2 & nn\\_struc/struct2 & im\\_te\\_2 & 0.8 & md\\_ev\\_5 \\\\\n", + "\\end{tabular}\n" + ], + "text/plain": [ + "\u001b[1m2×5 DataFrame\u001b[0m\n", + "\u001b[1m Row \u001b[0m│\u001b[1m im_train \u001b[0m\u001b[1m nn \u001b[0m\u001b[1m im_test \u001b[0m\u001b[1m acc \u001b[0m\u001b[1m md2 \u001b[0m\n", + " │\u001b[90m String? \u001b[0m\u001b[90m String? \u001b[0m\u001b[90m String? \u001b[0m\u001b[90m Float32? \u001b[0m\u001b[90m String? \u001b[0m\n", + "─────┼────────────────────────────────────────────────────────\n", + " 1 │ im_tr_1 nn_struc/struct1 im_te_1 0.9 md_ev_3\n", + " 2 │ im_tr_2 nn_struc/struct2 im_te_2 0.8 md_ev_5" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "execute(statement1, [0.6])" ]