昆明理工大学人工智能第二次实验报告Word格式文档下载.docx
- 文档编号:17667894
- 上传时间:2022-12-08
- 格式:DOCX
- 页数:11
- 大小:62.97KB
昆明理工大学人工智能第二次实验报告Word格式文档下载.docx
《昆明理工大学人工智能第二次实验报告Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《昆明理工大学人工智能第二次实验报告Word格式文档下载.docx(11页珍藏版)》请在冰豆网上搜索。
年月日
实验项目名称
天气决策树
指导教师
刘英莉
一、上机目的及内容
1.上机内容
用确定性推理算法求解教材65-66页介绍的八数码难题。
2.上机目的
(1)复习程序设计和数据结构课程的相关知识,实现课程间的平滑过渡;
(2)掌握并实现在小规模状态空间中进行图搜索的方法;
(3)理解并掌握图搜索的技术要点。
二、实验原理及基本技术路线图(方框原理图或程序流程图)
(1)设计并实现程序,求解出正确的解答路径;
(2)对所设计的算法采用大O符号进行时间复杂性和空间复杂性分析;
(3)对一般图搜索的技术要点和技术难点进行评述性分析。
三、所用仪器、材料(设备名称、型号、规格等或使用软件)
1台PC及VISUALC++6.0软件
四、实验方法、步骤(或:
程序代码或操作过程)
建立工程后建立5个sourceFiles文件分别为
1.AttributeValue.cpp
#include"
AttributeValue.h"
base.h"
AttributeValue:
:
AttributeValue(std:
stringconst&
instring)
m_value(instring)
{
}
boolAttributeValue:
GetType()
if(m_value=="
P"
)
{
returntrue;
}
elseif(m_value=="
N"
returnfalse;
else
throwDataErrException();
2.basefun.cpp
#include<
math.h>
floatlog2(floatx)
return1.0/log10
(2)*log10(x);
floatcalEntropy(floatprob)
floatsum=0;
if(prob==0||prob==1)
return0;
sum-=prob*log2(prob);
sum-=(1-prob)*log2(1-prob);
returnsum;
3.DataPoint.cpp
iostream>
DataPoint.h"
DataPoint:
DataPoint(std:
vector<
AttributeValue>
const&
attributes,booltype)
m_type(type)
for(inti=0;
i<
attributes.size();
++i)
m_attributes.push_back(attributes[i]);
voidDataPoint:
display()
m_attributes.size();
std:
cout<
<
"
\t"
<
m_attributes[i].getValue();
if(true==m_type)
\tP"
;
\tN"
std:
endl;
4.DataSet.cpp
5.main.cpp
fstream>
list>
sstream>
string>
vector>
DataSet.h"
DataPointprocessLine(std:
sLine)
istringstreamisLine(sLine,std:
istringstream:
in);
attributes;
//TODO:
needtohandlebeginningandendingemptyspaces.
while(isLine.good())
stringrawfield;
isLine>
>
rawfield;
attributes.push_back(AttributeValue(rawfield));
AttributeValuev=attributes.back();
attributes.pop_back();
booltype=v.GetType();
returnDataPoint(attributes,type);
voidmain()
ifstreamifs("
in.txt"
std:
ifstream:
DataSetinitDataset;
while(ifs.good())
//TODO:
needtohandleemptylines.
stringsLine;
getline(ifs,sLine);
initDataset.addDataPoint(processLine(sLine));
list<
DataSet>
processQ;
finishedDataSet;
processQ.push_back(initDataset);
while(processQ.size()>
0)
splittedDataSets;
DataSetdataset=processQ.front();
dataset.splitDataSet(splittedDataSets);
processQ.pop_front();
for(inti=0;
splittedDataSets.size();
{
floatprob=splittedDataSets[i].getPositiveProb();
if(prob==0.0||prob==1.0)
{
finishedDataSet.push_back(splittedDataSets[i]);
}
else
processQ.push_back(splittedDataSets[i]);
}
Thedicisiontreeis:
"
for(inti=0;
i<
finishedDataSet.size();
finishedDataSet[i].display();
建立4个HeaderFiles文件
1.AttributeValue.h
#ifndefATTRIBUTE_VALUE_H_
#defineATTRIBUTE_VALUE_H_
classAttributeValue
public:
AttributeValue(std:
instring);
boolGetType();
getValue()const
returnm_value;
private:
stringm_value;
};
structAttributeValueCmp
booloperator()(AttributeValueconst&
lhs,AttributeValueconst&
rhs)const
returnlhs.getValue()<
rhs.getValue();
#endif
2.base.h
classDataErrException:
publicstd:
exception
floatcalEntropy(floatprob);
3.DatePoint.h
#ifndefDATA_POINT_H_
#defineDATA_POINT_H_
classDataPoint
DataPoint(std:
attributes,booltype);
boolisPositive()
returnm_type;
intgetNAttributes()
returnm_attributes.size();
AttributeValueconst&
getAttribute(intindex)
returnm_attributes[index];
voiddisplay();
m_attributes;
boolm_type;
4.DateSet.h
map>
utility>
classSplitAttributeValue
SplitAttributeValue(AttributeValuev,intid)
:
m_v(v)
m_attributeIndex(id)
intgetAttributeIndex()
returnm_attributeIndex;
intm_attributeIndex;
AttributeValuem_v;
classDataSet
voidaddDataPoint(DataPointconst&
datapoint);
floatgetPositiveProb();
voidsplitDataSet(std:
&
splittedSets);
SplitAttributeValue>
m_splitAttributes;
DataPoint>
m_data;
五、实验过程原始记录(测试数据、图表、计算等)
实验运行截图
六、实验结果、分析和结论(误差分析与数据处理、成果总结等。
其中,绘制曲线图时必须用计算纸或程序运行结果、改进、收获)
这次事件让我的编程能力有了很大的提高,查阅资料等能力也有很大的提升。
让我对人工智能技术有了进一步的认识。
在解决问题和算法设计上的能力也极大地提高。
这次作业我收集相关材料阅读并消化,在实际应用中,我发现人工智能是一门很有意思的学科,对本门课程产生了兴趣。
在以后的学习中,我会认真学好这门课程。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 昆明 理工大学 人工智能 第二次 实验 报告