diff --git a/README.md b/README.md
index c6e19f6..22aa6c7 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
![Tests](https://github.com/AlgebraicJulia/AlgebraicRelations.jl/workflows/Tests/badge.svg)
AlgebraicRelations.jl is a Julia library built to provide an intuitive and
-elegant method for generating and querying a scientific database. This
+elegant method for generating and querying a scientific database. This
package provides tooling for defining database schemas,
generating query visualizations, and connecting directly up to a PostgreSQL
server. This package is built on top of
@@ -75,7 +75,7 @@ Once this presentation is defined, the database schema can be generated as follo
```julia
# Convert to Schema
-TrainDB = present_to_schema(present);
+@present_to_schema TrainDB(present);
print(generate_schema_sql(TrainDB()))
```
```sql
diff --git a/examples/company_demo/concise_demo_ACT.ipynb b/examples/company_demo/concise_demo_ACT.ipynb
index c07263e..fa9f5df 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": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -23,7 +23,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -44,26 +44,16 @@
" (:get_name, Person, Name)]);\n",
"\n",
"\n",
- "Workplace = present_to_schema(present)\n",
+ "Workplace = @present_to_schema TrainDB(present);\n",
+ "\n",
"schema = Workplace();"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
- "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);"
- ]
- }
- ],
+ "outputs": [],
"source": [
"print(generate_schema_sql(schema));"
]
@@ -78,155 +68,9 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
- "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"
- ],
- "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\"))"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"# We generate a query that gets all employees make a salary within some range\n",
"q1 = @query schema (emp_name, salary) where \n",
@@ -247,207 +91,9 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "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"
- ],
- "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\"))"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"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",
@@ -477,15 +123,15 @@
"lastKernelId": null
},
"kernelspec": {
- "display_name": "Julia 1.5.2",
+ "display_name": "Julia 1.8.3",
"language": "julia",
- "name": "julia-1.5"
+ "name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
- "version": "1.5.2"
+ "version": "1.8.3"
}
},
"nbformat": 4,
diff --git a/examples/ml_workflow_demo/ml_demo.ipynb b/examples/ml_workflow_demo/ml_demo.ipynb
index bf1d5a5..ba18f18 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": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -32,173 +32,9 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- "Catlab.Graphics.Graphviz.Graph(\"G\", true, \"dot\", Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(\"S_Files\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"circle\",:color => \"#6C9AC3\")), Catlab.Graphics.Graphviz.Node(\"S_Images\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"circle\",:color => \"#6C9AC3\")), Catlab.Graphics.Graphviz.Node(\"S_NeuralNet\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"circle\",:color => \"#6C9AC3\")), Catlab.Graphics.Graphviz.Node(\"S_Accuracy\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"circle\",:color => \"#6C9AC3\")), Catlab.Graphics.Graphviz.Node(\"S_Metadata\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"circle\",:color => \"#6C9AC3\")), Catlab.Graphics.Graphviz.Node(\"T_evaluate\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"square\",:color => \"#E28F41\")), Catlab.Graphics.Graphviz.Node(\"T_extract\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"square\",:color => \"#E28F41\")), Catlab.Graphics.Graphviz.Node(\"T_split\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"square\",:color => \"#E28F41\")), Catlab.Graphics.Graphviz.Node(\"T_train\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:shape => \"square\",:color => \"#E28F41\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"S_Images\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"T_evaluate\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")) … Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_evaluate\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_Metadata\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_evaluate\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_Accuracy\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"S_Files\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"T_extract\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_extract\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_Images\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"S_Images\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"T_split\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_split\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_Images\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"2\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"S_Images\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"T_train\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"S_NeuralNet\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"T_train\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_train\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_Metadata\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"T_train\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"S_NeuralNet\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:label => \"1\",:labelfontsize => \"6\"))], 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\"))"
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"# Initialize presentation object\n",
"present = Presentation()\n",
@@ -217,26 +53,15 @@
" (:train, NeuralNet⊗Images, NeuralNet⊗Metadata),\n",
" (:evaluate, NeuralNet⊗Images, Accuracy⊗Metadata)]);\n",
"# Convert to Schema\n",
- "TrainDB = present_to_schema(present);\n",
+ "TrainDB = @present_to_schema TrainDB(present);\n",
"draw_schema(present)"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
- "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);"
- ]
- }
- ],
+ "outputs": [],
"source": [
"print(generate_schema_sql(TrainDB()))"
]
@@ -251,116 +76,9 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "image/svg+xml": [
- "\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(\"n1p1\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"in1\")), Catlab.Graphics.Graphviz.Node(\"n1p2\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"in2\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1p1\", \"\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n1p2\", \"\", \"\")], 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(\"n2p1\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:id => \"out1\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n2p1\", \"\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}())], 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(\"n3\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"extract\",:id => \"n3\",:label => Catlab.Graphics.Graphviz.Html(\"
\\n\\n | \\nextract | \\n | \\n
\\n
\"))), Catlab.Graphics.Graphviz.Node(\"n4\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"split\",:id => \"n4\",:label => Catlab.Graphics.Graphviz.Html(\"\"))), Catlab.Graphics.Graphviz.Node(\"n5\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"train\",:id => \"n5\",:label => Catlab.Graphics.Graphviz.Html(\"\"))), Catlab.Graphics.Graphviz.Node(\"n6\", OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"evaluate\",:id => \"n6\",:label => Catlab.Graphics.Graphviz.Html(\"\\n\\n | \\nevaluate | \\n | \\n
\\n
\"))), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n1p2\", \"e\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n3\", \"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(\"n5\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n6\", \"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(\"n4\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n5\", \"in2\", \"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 => \"Images\",:id => \"e4\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n6\", \"out1\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n2p1\", \"w\", \"\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"Accuracy\",:id => \"e5\")), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(\"n4\", \"out2\", \"e\"), Catlab.Graphics.Graphviz.NodeID(\"n6\", \"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(\"n1p1\", \"e\", \"\"), Catlab.Graphics.Graphviz.NodeID(\"n5\", \"in1\", \"w\")], OrderedCollections.OrderedDict{Symbol,Union{String, Catlab.Graphics.Graphviz.Html}}(:comment => \"NeuralNet\",: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\"))"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"p = @program present (nn::NeuralNet, file::Files) begin\n",
" images = extract(file)\n",
@@ -420,226 +138,9 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "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"
- ],
- "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\"))"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"q = @query TrainDB() (im_train, nn, im_test, acc, md2) where (im_train, im_test, nn,\n",
" nn_trained, acc, md,\n",
@@ -663,7 +164,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -672,7 +173,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -681,38 +182,9 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- " | im_train | nn | im_test | acc | md2 |
---|
| String? | String? | String? | Float32? | String? |
---|
2 rows × 5 columns
1 | im_tr_1 | nn_struc/struct1 | im_te_1 | 0.9 | md_ev_3 |
---|
2 | im_tr_2 | nn_struc/struct2 | im_te_2 | 0.8 | md_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": [
- "2×5 DataFrame\n",
- "│ Row │ im_train │ nn │ im_test │ acc │ md2 │\n",
- "│ │ \u001b[90mString?\u001b[39m │ \u001b[90mString?\u001b[39m │ \u001b[90mString?\u001b[39m │ \u001b[90mFloat32?\u001b[39m │ \u001b[90mString?\u001b[39m │\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 │"
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"execute(statement1, [0.6])"
]
@@ -724,15 +196,15 @@
"lastKernelId": null
},
"kernelspec": {
- "display_name": "Julia 1.5.2",
+ "display_name": "Julia 1.8.3",
"language": "julia",
- "name": "julia-1.5"
+ "name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
- "version": "1.5.2"
+ "version": "1.8.3"
}
},
"nbformat": 4,