Skip to content

Commit 87f8d14

Browse files
authored
Add files via upload
1 parent 5ee00f1 commit 87f8d14

File tree

6 files changed

+124
-0
lines changed

6 files changed

+124
-0
lines changed

examples/grand_parent/BK.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mother(ann,amy).
2+
mother(ann,andy).
3+
mother(amy,amelia).
4+
mother(linda,gavin).
5+
father(steve,amy).
6+
father(steve,andy).
7+
father(gavin,amelia).
8+
father(andy,spongebob).

examples/grand_parent/GP_Neg_BC

59 Bytes
Binary file not shown.

examples/grand_parent/GP_Pos_BC

435 Bytes
Binary file not shown.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"id": "a010cc36-208c-4d24-b497-1fe995f8655e",
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": 3,
18+
"id": "282f8582-0231-46c8-943a-4f324c1d053d",
19+
"metadata": {},
20+
"outputs": [
21+
{
22+
"name": "stderr",
23+
"output_type": "stream",
24+
"text": [
25+
"100%|███████████████████████████████████████████| 5/5 [00:00<00:00, 1464.59it/s]\n",
26+
"100%|████████████████████████████████████████████| 1/1 [00:00<00:00, 734.81it/s]\n",
27+
"100%|███████████████████████████████████████████| 5/5 [00:00<00:00, 1425.37it/s]\n",
28+
"100%|███████████████████████████████████████████| 1/1 [00:00<00:00, 3521.67it/s]"
29+
]
30+
},
31+
{
32+
"name": "stdout",
33+
"output_type": "stream",
34+
"text": [
35+
"+----------+ Hypothesis +----------+\n",
36+
"['grandparent(A,B):-p_0(A,C),p_0(C,B)', 'p_0(A,B):-mother(A,B)', 'p_0(A,B):-father(A,B)']\n",
37+
"+----------+ Training +----------+\n",
38+
"+---------------------+------------------+------------------+\n",
39+
"| n = 6 | Positive(Actual) | Negative(Actual) |\n",
40+
"+=====================+==================+==================+\n",
41+
"| Positive(Predicted) | 5 | 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= \"GP_Pos_BC\", negative_file_dictionary = \"GP_Neg_BC\")\n",
73+
"Train_P, Test_P, Train_N, Test_N = pygol_train_test_split(test_size= 0, \n",
74+
" positive_file_dictionary= \"GP_Pos_BC\", \n",
75+
" negative_file_dictionary = \"GP_Neg_BC\")\n",
76+
"model= pygol_learn(Train_P, Train_N, constant_set = constant, max_neg = 0, file = \"BK.pl\",\n",
77+
" max_literals = 2, key_size = 4, set_chain = True, rule_noise_check = True, pi = True)"
78+
]
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": null,
83+
"id": "61cb63ee-0eec-41ec-aee5-e99810361b1d",
84+
"metadata": {},
85+
"outputs": [],
86+
"source": []
87+
}
88+
],
89+
"metadata": {
90+
"kernelspec": {
91+
"display_name": "Python 3 (ipykernel)",
92+
"language": "python",
93+
"name": "python3"
94+
},
95+
"language_info": {
96+
"codemirror_mode": {
97+
"name": "ipython",
98+
"version": 3
99+
},
100+
"file_extension": ".py",
101+
"mimetype": "text/x-python",
102+
"name": "python",
103+
"nbconvert_exporter": "python",
104+
"pygments_lexer": "ipython3",
105+
"version": "3.12.2"
106+
}
107+
},
108+
"nbformat": 4,
109+
"nbformat_minor": 5
110+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
grandparent(amy,amelia).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
grandparent(ann,amelia).
2+
grandparent(steve,amelia).
3+
grandparent(ann,spongebob).
4+
grandparent(steve,spongebob).
5+
grandparent(linda,amelia).

0 commit comments

Comments
 (0)