|
| 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 | +} |
0 commit comments