Skip to content

Commit a7097b0

Browse files
authored
Add files via upload
1 parent 21f36e0 commit a7097b0

File tree

6 files changed

+127
-0
lines changed

6 files changed

+127
-0
lines changed

examples/ancestor/Ancestor_Neg_BC

157 Bytes
Binary file not shown.

examples/ancestor/Ancestor_Pos_BC

349 Bytes
Binary file not shown.

examples/ancestor/BK.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parent(queen_victoria,edward_seventh).
2+
parent(edward_seventh,george_fifth).
3+
parent(george_fifth,george_sixth).
4+
parent(george_sixth,elizabeth_second).
5+
parent(queen_mother,elizabeth_second).
6+
parent(elizabeth_second,prince_charles).
7+
parent(prince_philip,prince_charles).
8+
parent(prince_charles,prince_william).
9+
parent(prince_charles,prince_harry).
10+
parent(princess_diana,prince_william).
11+
parent(princess_diana,prince_harry).
12+
parent(prince_william,prince_george).
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 4,
6+
"id": "b6680ca5-3282-4f04-aa8b-042be4a26ff1",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import sys\n",
11+
"sys.path.insert(0, '../../')\n",
12+
"from PyGol import *"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": 5,
18+
"id": "0fa1e253-1f36-447e-a7e4-ffbe5ab72fd5",
19+
"metadata": {},
20+
"outputs": [
21+
{
22+
"name": "stderr",
23+
"output_type": "stream",
24+
"text": [
25+
"100%|███████████████████████████████████████████| 3/3 [00:00<00:00, 1543.35it/s]\n",
26+
"100%|████████████████████████████████████████████| 1/1 [00:00<00:00, 974.74it/s]\n",
27+
"100%|████████████████████████████████████████████| 3/3 [00:00<00:00, 790.53it/s]\n",
28+
"100%|████████████████████████████████████████████| 1/1 [00:00<00:00, 339.56it/s]"
29+
]
30+
},
31+
{
32+
"name": "stdout",
33+
"output_type": "stream",
34+
"text": [
35+
"+----------+ Hypothesis +----------+\n",
36+
"['ancestor(A,B):-parent(A,B)', 'ancestor(A,B):-parent(A,C),ancestor(C,B)']\n",
37+
"+----------+ Training +----------+\n",
38+
"+---------------------+------------------+------------------+\n",
39+
"| n = 4 | Positive(Actual) | Negative(Actual) |\n",
40+
"+=====================+==================+==================+\n",
41+
"| Positive(Predicted) | 3 | 0 |\n",
42+
"+---------------------+------------------+------------------+\n",
43+
"| Negative(Predicted) | 0 | 1 |\n",
44+
"+---------------------+------------------+------------------+\n",
45+
"+-------------+---+\n",
46+
"| Metric | # |\n",
47+
"+=============+===+\n",
48+
"| Accuracy | 1 |\n",
49+
"+-------------+---+\n",
50+
"| Precision | 1 |\n",
51+
"+-------------+---+\n",
52+
"| Sensitivity | 1 |\n",
53+
"+-------------+---+\n",
54+
"| Specificity | 1 |\n",
55+
"+-------------+---+\n",
56+
"| F1 Score | 1 |\n",
57+
"+-------------+---+\n"
58+
]
59+
},
60+
{
61+
"name": "stderr",
62+
"output_type": "stream",
63+
"text": [
64+
"\n"
65+
]
66+
}
67+
],
68+
"source": [
69+
"constant = []\n",
70+
"P, N = bottom_clause_generation(constant_set = constant, container = \"dict\", file = \"BK.pl\",\n",
71+
" positive_example = \"pos_example.f\", negative_example = \"neg_example.n\",\n",
72+
" positive_file_dictionary= \"Ancestor_Pos_BC\", \n",
73+
" negative_file_dictionary = \"Ancestor_Neg_BC\")\n",
74+
"Train_P, Test_P, Train_N, Test_N = pygol_train_test_split(test_size= 0, \n",
75+
" positive_file_dictionary= \"Ancestor_Pos_BC\", \n",
76+
" negative_file_dictionary = \"Ancestor_Neg_BC\")\n",
77+
"model= pygol_learn(Train_P, Train_N, constant_set = constant, max_neg = 0, file = \"BK.pl\",\n",
78+
" max_literals = 5, key_size = 3, rule_noise_check = True, recursive = True)"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"id": "298a34f8-17df-4cdb-a4c9-da25b06eca59",
85+
"metadata": {},
86+
"outputs": [],
87+
"source": []
88+
}
89+
],
90+
"metadata": {
91+
"kernelspec": {
92+
"display_name": "Python 3 (ipykernel)",
93+
"language": "python",
94+
"name": "python3"
95+
},
96+
"language_info": {
97+
"codemirror_mode": {
98+
"name": "ipython",
99+
"version": 3
100+
},
101+
"file_extension": ".py",
102+
"mimetype": "text/x-python",
103+
"name": "python",
104+
"nbconvert_exporter": "python",
105+
"pygments_lexer": "ipython3",
106+
"version": "3.12.2"
107+
}
108+
},
109+
"nbformat": 4,
110+
"nbformat_minor": 5
111+
}

examples/ancestor/neg_example.n

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ancestor(princess_diana,queen_mother)

examples/ancestor/pos_example.f

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ancestor(elizabeth_second,prince_charles).
2+
ancestor(george_sixth,prince_harry).
3+
ancestor(queen_mother,prince_william).

0 commit comments

Comments
 (0)