AI-动物识别

优惠券 m.fenfaw.net

一、实验目的

1. 理解产生式系统的结构原理与实际应用。 
2. 掌握产生式规则表示及规则库组建的实现方法。 
3. 熟悉和掌握产生式系统的运行机制,掌握基于规则推理的基本方法。

二、实验原理

   产生式系统用来描述若干个不同的以一个基本概念为基础的系统,这个基本概念就是产生式规则或产生式条件和操作对。在产生式系统中,论域的知识分为两部分:用事实表示静态知识;用产生式规则表示推理过程和行为

1.实验要求

运用所学知识,设计并编程一个小型的动物识别系统,识别对象:虎、金钱豹、斑马、长颈鹿、鸵鸟、企鹅、信天翁 七种动物

2.识别规则库

R1:  有毛(1)  --> 哺乳动物(12)
R2:  有奶(2)  --> 哺乳动物(12)
R3:  有羽毛(3)   --> 鸟类(13)
R4:  会飞(4) & 会下蛋  --> 鸟类(13)
R5:  吃肉(6)  --> 食肉动物(14)
R6:  犬齿(7) & 有爪(8) & 盯前方(9)  --> 食肉动物(14)
R7:  哺乳动物(12) & 有蹄(10)  -->  有蹄类动物(15)
R8:  哺乳动物(12) & 反刍(11)  -->  有蹄类动物(15)
R9:  哺乳动物(12) & 食肉动物(14) & 黄褐色(16) & 暗斑点(17)  --> 金钱豹(a)
R10: 哺乳动物(12) & 食肉动物(14) & 黄褐色(16) & 黑色条纹(18)  --> 虎(b)
R11: 有蹄类动物(15) & 长脖(19) & 长腿(20) & 暗斑色(17)  --> 长颈鹿(c)
R12: 有蹄类动物(15) & 黑色条纹(18) &  -->  斑马(d)
R13: 鸟类(13) & 长脖(19) & 长腿(20) & 不会飞(21) & 黑白两色(22)  -->  鸵鸟(e)
R14: 鸟类(13) & 会游泳(23) & 不会飞(21) & 黑白二色(22)  -->  企鹅(f)
R15: 鸟类(13) & 善飞(24)  -->  信天翁(g)

以上为:动物识别规则的15条规则,已编码

3.思路分析

  1. 第一次编写时:采用的是,条件对应原则,每个条件对应的动物做一个集合,多个条件集合取交集,得到对应动物。方法-错误×,未使用该15条规则,推理而得。

    如:当选择 条件不会飞 和 会飞时,集合方式无法推理出结果,- 会飞 && 会下蛋  -->  鸟类- 鸟类 && 不会飞 && 会游泳 && 黑白二色  --> 企鹅+ 输入条件:- 会飞 && 会下蛋 && 不会飞 && 会游泳 && 黑白二色  -×-> 企鹅
    
  2. 改版,版本2.0,重新设计对应方式:

    通过两个数组: - two1 = []    // 存放单击选择的条件- three = []   // 初始值为 13个 0 组成的数组
    1. 遍历 选择的条件数组: two1[]  2. 将拿到的数组结果,依次 if 判断,如:- 有羽毛(3) 则 将 three 的three[1] = 13 - 依次类推
    3. 最后拿到结果:three[] 数组,满足对应条件,而重新赋值的数组,进行判断:如:信天翁判断-  if ( this.three[1] == 13 && this.three[12] == 24 &&this.three[0] == 0 && this.three[2] == 0 && this.three[3] == 0 &&this.three[4] == 0 && this.three[5] == 0 && this.three[6] == 0 &&this.three[7] == 0 && this.three[8] == 0 && this.three[9] == 0 &&this.three[10] == 0 && this.three[11] == 0 )- 则为 :信天翁
    

三、实验内容

1. 实验要求

  1. 实现可以输入任何的事实,并基于原有的规则和输入的事实进行推理

2.遍历-数组规则

  1. 由点击传入 two1 数组 的值,为 three数组 赋值

            /*遍历所有的规则,得到最好结果*/for (let i = 0;i<cond.length;i++){// 有毛 || 有奶 ---> 哺乳animalif (cond[i] == 1) this.three[0]=12if (cond[i] == 2) this.three[0]=12// 有羽毛 || (会飞&会下蛋) --->  鸟if (cond[i] == 3) this.three[1]=13if (cond[i] == 4) {this.three[1] = 1for (let n=0;n<cond.length;n++){if (cond[n] == 5){this.three[1]=13}}}if (cond[i] == 5) {this.three[1] = 1for (let n=0;n<cond.length;n++){if (cond[n] == 4){this.three[1]=13}}}// 吃肉 || (犬齿 & 有爪 & 盯前方) ----> 食肉animalif (cond[i] == 6) this.three[2]=14if (cond[i] == 7) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 8) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 9) {this.three[2] = 14console.log("循环次数:")break}}break}else if (cond[n] == 9){this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 8) {this.three[2] = 14break}}break}}}if (cond[i] == 8) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 7) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 9) {this.three[2] = 14break}}break} else if (cond[n] == 9) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 7) {this.three[2] = 14break}}break}}}if (cond[i] == 9) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 7) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 8) {this.three[2] = 14break}}break} else if (cond[n] == 8) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 7) {this.three[2] = 14break}}break}}}// (哺乳 & 有蹄)|| (哺乳 & 反刍)  ---> 有蹄类动物if (this.three[0] == 12 && cond[i] == 10) this.three[3]=15if (this.three[0] == 12 && cond[i] == 11) this.three[3]=15// 以下是,判断是什么动物// 黄褐色if (cond[i] == 16) this.three[4]=16// 暗斑色if (cond[i] == 17) this.three[5]=17// 黑色条纹if (cond[i] == 18) this.three[6]=18// 长脖if (cond[i] == 19) this.three[7]=19// 长腿if (cond[i] == 20) this.three[8]=20// 不会飞if (cond[i] == 21) this.three[9]=21// 黑白两色if (cond[i] == 22) this.three[10]=22// 会游泳if (cond[i] == 23) this.three[11]=23// 善飞if (cond[i] == 24) this.three[12]=24}

四、实验过程

1.源代码

<template><div><h2>以下是:版本2.0</h2><!-- 按钮区域 --><div class="change"><button @click="onclick1(1)">有毛</button><button @click="onclick1(2)">有奶</button><button @click="onclick1(3)">有羽毛</button><button @click="onclick1(4)">会飞</button><button @click="onclick1(5)">会下蛋</button><button @click="onclick1(6)">吃肉</button><br/><button @click="onclick1(7)">犬齿</button><button @click="onclick1(8)">有爪</button><button @click="onclick1(9)">盯前方</button><button @click="onclick1(10)">有蹄</button><button @click="onclick1(11)">反刍</button><button @click="onclick1(16)">黄褐色</button><button @click="onclick1(17)">暗斑色</button><br/><button @click="onclick1(18)">黑色条纹</button><button @click="onclick1(19)">长脖子</button><button @click="onclick1(20)">长腿</button><button @click="onclick1(21)">不会飞</button><button @click="onclick1(22)">黑白</button><button @click="onclick1(23)">会游泳</button><button @click="onclick1(24)">善飞</button></div><br><br><div><!--确定按钮--><button @click="ruleAnimal()">确定</button><button @click="clean()">清空</button></div><br><br><!-- 2.0结果输出区 --><div><h4>{{this.overChoose}}</h4><h3>{{this.animalResult1}}</h3><h5>{{this.three}}</h5></div></div></template><script>import '@/assets/less/TableExpand.less'import PictModal from './modules/PictModal'export default {name: "PictList",components: {PictModal},data () {return {/*版本2.0*/two1: [],three: [],animalResult1:'',overChoose:''}},created() {for (let i = 0;i<13;i++){this.three.push(0)}},methods: {       /** 版本2.0* */onclick1(e){/* 将点击按钮后,将对应按钮的数字,push 到 two【】数组里*/this.two1.push(e)},/*清空three数组*/clean(){this.three = []this.two1 = []for (let i = 0;i<13;i++){this.three.push(0)}},ruleAnimal(){console.log("输出已经选择的条件编码:"+this.two1)for (let i = 0;i<this.two1.length;i++){if (this.two1[i] == 1){console.log("有毛")}else if (this.two1[i] == 2){console.log("有奶")}else if (this.two1[i] == 3){console.log("有羽毛")}else if (this.two1[i] == 4){console.log("会飞")}else if (this.two1[i] == 5){console.log("会下蛋")}else if (this.two1[i] == 6){console.log("吃肉")}else if (this.two1[i] == 7){console.log("犬齿")}else if (this.two1[i] == 8){console.log("有爪")}else if (this.two1[i] == 9){console.log("盯前方")}else if (this.two1[i] == 10){console.log("有蹄")}else if (this.two1[i] == 11){console.log("反刍")}else if (this.two1[i] == 16){console.log("黄褐色")}else if (this.two1[i] == 17){console.log("暗斑色")}else if (this.two1[i] == 18){console.log("黑色条纹")}else if (this.two1[i] == 19){console.log("长脖子")}else if (this.two1[i] == 20){console.log("长腿")}else if (this.two1[i] == 21){console.log("不会飞")}else if (this.two1[i] == 22){console.log("黑白")}else if (this.two1[i] == 23){console.log("会游泳")}else if (this.two1[i] == 24){console.log("善飞")}}this.overChoose = this.two1//定义一个数组变量condition:存储 this.two1let cond = this.two1/*遍历所有的规则,得到最好结果*/for (let i = 0;i<cond.length;i++){// 有毛 || 有奶 ---> 哺乳animalif (cond[i] == 1) this.three[0]=12if (cond[i] == 2) this.three[0]=12// 有羽毛 || (会飞&会下蛋) --->  鸟if (cond[i] == 3) this.three[1]=13if (cond[i] == 4) {this.three[1] = 1for (let n=0;n<cond.length;n++){if (cond[n] == 5){this.three[1]=13}}}if (cond[i] == 5) {this.three[1] = 1for (let n=0;n<cond.length;n++){if (cond[n] == 4){this.three[1]=13}}}// 吃肉 || (犬齿 & 有爪 & 盯前方) ----> 食肉animalif (cond[i] == 6) this.three[2]=14if (cond[i] == 7) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 8) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 9) {this.three[2] = 14console.log("循环次数:")break}}break}else if (cond[n] == 9){this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 8) {this.three[2] = 14break}}break}}}if (cond[i] == 8) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 7) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 9) {this.three[2] = 14break}}break} else if (cond[n] == 9) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 7) {this.three[2] = 14break}}break}}}if (cond[i] == 9) {this.three[2] = 4for (let n = 0; n < cond.length; n++) {if (cond[n] == 7) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 8) {this.three[2] = 14break}}break} else if (cond[n] == 8) {this.three[2] = 4for (let m = 0; m < cond.length; m++) {if (cond[m] == 7) {this.three[2] = 14break}}break}}}// (哺乳 & 有蹄)|| (哺乳 & 反刍)  ---> 有蹄类动物if (this.three[0] == 12 && cond[i] == 10) this.three[3]=15if (this.three[0] == 12 && cond[i] == 11) this.three[3]=15// 以下是,判断是什么动物// 黄褐色if (cond[i] == 16) this.three[4]=16// 暗斑色if (cond[i] == 17) this.three[5]=17// 黑色条纹if (cond[i] == 18) this.three[6]=18// 长脖if (cond[i] == 19) this.three[7]=19// 长腿if (cond[i] == 20) this.three[8]=20// 不会飞if (cond[i] == 21) this.three[9]=21// 黑白两色if (cond[i] == 22) this.three[10]=22// 会游泳if (cond[i] == 23) this.three[11]=23// 善飞if (cond[i] == 24) this.three[12]=24}/* 进行动物规则 判断*/// 哺乳 & 食肉 & 黄褐色 & 暗斑色 --> 金钱豹if (this.three[0] == 12 && this.three[2] == 14 && this.three[4] == 16 && this.three[5] == 17 &&this.three[1] == 0 && this.three[3] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[6] == 0 && this.three[9] == 0 &&this.three[11] == 0 && this.three[12] == 0 && this.three[10] == 0){this.animalResult1 = "金钱豹"console.log("这里是金钱豹:")}else if (this.three[0] == 12 && this.three[2] == 14 && this.three[4] == 16 && this.three[6] == 18 &&this.three[1] == 0 && this.three[3] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[5] == 0 && this.three[9] == 0 &&this.three[11] == 0 && this.three[12] == 0 && this.three[10] == 0){this.animalResult1 = "虎"console.log("这里是虎:")}else if (this.three[3] == 15 && this.three[7] == 19 && this.three[8] == 20 && this.three[5] == 17 && this.three[0] == 12 &&this.three[2] == 0 && this.three[1] == 0 && this.three[4] == 0 &&this.three[9] == 0 && this.three[6] == 0 && this.three[11] == 0 &&this.three[12] == 0 && this.three[10] == 0){this.animalResult1 = "长颈鹿"console.log("这里是长颈鹿:")}else if (this.three[3] == 15 && this.three[6] == 18 && this.three[0] == 12 &&this.three[2] == 0 && this.three[1] == 0 &&this.three[4] == 0 && this.three[5] == 0 && this.three[12] == 0 &&this.three[7] == 0 && this.three[8] == 0 && this.three[9] == 0 &&this.three[10] == 0 && this.three[11] == 0 ){this.animalResult1 = "斑马"console.log("这里是斑马:")}else if (this.three[1] == 13 && this.three[7] == 19 && this.three[8] == 20 && this.three[9] == 21 && this.three[10] == 22 &&this.three[2] == 0 && this.three[3] == 0 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[0] == 0 &&this.three[11] == 0 && this.three[12] == 0){this.animalResult1 = "鸵鸟"console.log("这里是鸵鸟:")}else if (this.three[1] == 13 && this.three[11] == 23 && this.three[9] == 21 && this.three[10] ==22 &&this.three[2] == 0 && this.three[3] == 0 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[12] == 0 &&this.three[0] == 0 ){this.animalResult1 = "企鹅"console.log("这里是企鹅:")}else if (this.three[1] == 13 && this.three[12] == 24 &&this.three[0] == 0 && this.three[2] == 0 && this.three[3] == 0 &&this.three[4] == 0 && this.three[5] == 0 && this.three[6] == 0 &&this.three[7] == 0 && this.three[8] == 0 && this.three[9] == 0 &&this.three[10] == 0 && this.three[11] == 0 ){this.animalResult1 = "信天翁"console.log("这里是信天翁:")}else if (this.three[1] == 0 && this.three[11] == 0 && this.three[9] == 0 && this.three[10] ==0 &&this.three[2] == 0 && this.three[3] == 0 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[12] == 0 &&this.three[0] == 12 ){this.animalResult1 = "哺乳动物"console.log("这里是哺乳动物:")}else if (this.three[1] == 13 && this.three[11] == 0 && this.three[9] == 0 && this.three[10] ==0 &&this.three[2] == 0 && this.three[3] == 0 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[12] == 0 &&this.three[0] == 0 ){this.animalResult1 = "鸟类动物"console.log("这里是鸟类动物:")}else if (this.three[1] == 0 && this.three[11] == 0 && this.three[9] == 0 && this.three[10] ==0 &&this.three[2] == 14 && this.three[3] == 0 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[12] == 0 &&this.three[0] == 0 ){this.animalResult1 = "食肉动物"console.log("这里是食肉动物:")}else if (this.three[1] == 0 && this.three[11] == 0 && this.three[9] == 0 && this.three[10] ==0 &&this.three[2] == 0 && this.three[3] == 15 && this.three[4] == 0 &&this.three[5] == 0 && this.three[6] == 0 && this.three[7] == 0 &&this.three[8] == 0 && this.three[12] == 0 &&this.three[0] == 12 ){this.animalResult1 = "有蹄动物"console.log("这里是有蹄动物:")}else {this.animalResult1 = "无法推理出何种动物"}},}}
</script>
<style scoped>@import '~@assets/less/common.less';
</style>

五、实验结果

1.规则R1:

有毛(1)  --> 哺乳动物(12)

2.规则R2:

 有奶(2)  --> 哺乳动物(12)

3. 规则R3:

R3:  有羽毛(3)   --> 鸟类(13)

4.规则R4:

R4:  会飞(4) & 会下蛋  --> 鸟类(13)

5.规则R5:

R5:  吃肉(6)  --> 食肉动物(14)

6.规则R6:

R6:  犬齿(7) & 有爪(8) & 盯前方(9)  --> 食肉动物(14)

7.规则R7:

R7:  哺乳动物(12) & 有蹄(10)  -->  有蹄类动物(15)

8.规则R8:

R8:  哺乳动物(12) & 反刍(11)  -->  有蹄类动物(15)

9.规则R9:

R9:  哺乳动物(12) & 食肉动物(14) & 黄褐色(16) & 暗斑点(17)  --> 金钱豹(a)

10.规则R10:

R10: 哺乳动物(12) & 食肉动物(14) & 黄褐色(16) & 黑色条纹(18)  --> 虎(b)

11.规则R11:

R11: 有蹄类动物(15) & 长脖(19) & 长腿(20) & 暗斑色(17)  --> 长颈鹿(c)

12.规则R12:

R12: 有蹄类动物(15) & 黑色条纹(18) &  -->  斑马(d)

13.规则R13:

R13: 鸟类(13) & 长脖(19) & 长腿(20) & 不会飞(21) & 黑白两色(22)  -->  鸵鸟(e)

14.规则R14:

R14: 鸟类(13) & 会游泳(23) & 不会飞(21) & 黑白二色(22)  -->  企鹅(f)

15.规则R15:

R15: 鸟类(13) & 善飞(24)  -->  信天翁(g)

AI实验-七种动物识别系统相关推荐

  1. c语言产生式系统动物识别系统,简单动物识别系统的知识表示实验报告

    简单动物识别系统的知识表示实验报告 一. 实验目的: 1. 2. 理解和掌握产生式知识表示方法. 能够用选定的编程语言实现产生式系统的规则库. 二. 实验内容和要求: 1.以动物识别系统的产生式规则为 ...

  2. 动物识别系统 python实现+UI

    完整代码在最下方 实验目的 利用动物识别系统来验证基于符号的推理,通过实验理解简单的专家系统所包含的模块:人机结构,知识获取机构,知识库及管理系系统,推理机,解释机构,数据库及管理系统". ...

  3. 人工智能实验-动物识别系统

    ** 实验一:产生式系统实验 ** 一.实验目的: 熟悉一阶谓词逻辑和产生式表示法,掌握产生式系统的运行机制,以及基于规则推理的基本方法. 二.实验内容: 设计并编程实现一个小型产生式系统(如分类.诊 ...

  4. 【AI】基于产生式规则的动物识别系统

    产生式系统 --动物识别系统 一.实验目的 二.实验原理 三.算法设计 四.系统代码设计 一.实验目的 [实验内容] 开发一个可以识别虎.金钱豹.斑马.长颈鹿.企鹅.鸵鸟.信天翁等7种动物的产生式系统 ...

  5. 人工智能实验:动物识别系统(C++代码实现)

    问题描述 建立一个动物识别系统的规则库,编写程序用以识别虎.豹.斑马.长颈鹿.企鹅.鸵鸟.信天翁等7种动物. 为了识别这些动物,可以根据动物识别的特征,建立包含下述规则库: R1:if 动物有毛发 t ...

  6. 动物识别系统代码python_动物识别 python 人工智能实验

    构建动物识别系统 系统分为两部分,第一部分是初始化综合数据库,分为两类,一类是间接数据库,即不指向最终动物的信息.另一类是直接数据库,即指向最终动物的信息.使用的是二维列表加上一个一维列表存储key与 ...

  7. AI-七种动物识别规则库

    文章目录 AI-动物识别 一.实验目的 二.实验原理 1.实验要求 2.识别规则库 3.思路分析 三.实验内容 1. 实验要求 2.遍历-数组规则 四.实验过程 1.源代码 五.实验结果 1.规则R1 ...

  8. 基于产生式表示的动物识别系统

      实验目的 理解和掌握产生式知识表示方法及产生式系统的基本过程,能够利用编程技术建立一个基于产生式知识表示的简单的智能系统. 例    建立一个动物识别系统的规则库,用以识别虎.豹.斑马.长颈鹿.企 ...

  9. 动物识别系统代码python_动物识别系统 代码

    1 动物识别专家系统 动物识别专家系统是流行的专家系统实验模型,它用产生式规则来表示知 识,共 15 条规则.可以识别七种动物,这些规则既少又简单,可以改造他 们,也可以加进新的规则,还可以用来识别其 ...

最新文章

  1. java非阻塞 串口读数据_串口阻塞与非阻塞
  2. 网工的常规操作:配置动态NAT
  3. JPA 2.1类型转换器–保留枚举的更好方法
  4. 中英对照 关于计算机的科技英语,《计算机专业英语》(中英文对照).pdf
  5. 程序员的算法课(8)-贪心算法:理解霍夫曼编码
  6. python zip dict_关于python:zip(list)和zip(* list)之间的区别
  7. 《团队作业第三、第四周》五小福团队作业--Scrum 冲刺阶段--Day7
  8. 【百度分享】javascript中函数调用过程中的this .
  9. 秃头程序员保姆教程:Spring框架自学之路(一)
  10. LiveZilla-最好的免费在线客服
  11. 导入Zip bomb detected
  12. Can not import avx core while this file exists
  13. Java 语言有哪些特点?
  14. oracle归档日志百分比,oracle归档日志过满清理
  15. 如何将kindle上的书导出成epub格式
  16. 数据挖掘入门必看的几个问题
  17. 鸿蒙系统预计什么时候上市,鸿蒙系统什么时候上市?鸿蒙系统什么时候用于手机(图文)...
  18. C语言 —— 函数(一)
  19. 广东python编程比赛
  20. 武汉大学服务器项目投标函,武汉大学

热门文章

  1. 游戏客户端安全方案。
  2. lol祖安服务器维护,LOL:最坑的十个大区,艾欧尼亚排第十!如果你在第一赶快换区!...
  3. MA8601 无需更改电路直接pin√pin替代FE8.1s方案
  4. 苹果申请新专利,iPhone或取消刘海设计
  5. C语言如何做出简易贪食蛇
  6. 工厂软件支持及测试是什么,软件工厂
  7. Edge上的gmail网页改为纯文字模式后改不回标准模式(HTML Gmail)问题和解决方法
  8. 【转载】VS2019使用技巧
  9. ASUS华硕天选2 FX506H INTELI711代CPU 原装出厂系统恢复原厂系统
  10. c语言鸡兔同笼(二)