英语翻译Example:Using the text-based interfaceHere is an example of using the text-based interface.The graphical interface suffices for most purposes,so you probably will not have to use the text-based interface.However,take a look at the list of
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 20:02:21
英语翻译Example:Using the text-based interfaceHere is an example of using the text-based interface.The graphical interface suffices for most purposes,so you probably will not have to use the text-based interface.However,take a look at the list of
英语翻译
Example:Using the text-based interface
Here is an example of using the text-based interface.The graphical interface suffices for most purposes,so you probably will not have to use the text-based interface.However,take a look at the list of available algorithms,below.
##load data set
>> load datasets/clouds
>> whos
Name Size Bytes Class
distribution_parameters 1x2 1464 struct array
patterns 2x5000 80000 double array
targets 1x5000 40000 double array
Grand total is 15076 elements using 121464 bytes
Data sets are stored as two variables in Matlab,patterns and targets.
## Choose test methods,training data and test data
%Make a draw according to the error method chosen
>> L = length(targets);
percent=20;
[test_indices,train_indices] = make_a_draw(floor(percent/100*L),L);
train_patterns = patterns(:,train_indices);
train_targets = targets (:,train_indices);
test_patterns = patterns(:,test_indices);
test_targets = targets (:,test_indices);
## Choose a classifier.Find out parameters using help
>> help Nearest_Neighbor
Classify using the Nearest neighbor algorithm
Inputs:
\x05train_patterns\x05- Train patterns
\x05train_targets\x05- Train targets
test_patterns - Test patterns
\x05Knn\x05\x05 - Number of nearest neighbors
Outputs
\x05test_targets\x05- Predicted targets
## Build the classifier and classify the data
>> test_out=Nearest_Neighbor(train_patterns,train_targets,test_patterns,3);
## Estimate the error
>>error=mean(test_targets = test_out)
error =
0.1313
英语翻译Example:Using the text-based interfaceHere is an example of using the text-based interface.The graphical interface suffices for most purposes,so you probably will not have to use the text-based interface.However,take a look at the list of
例如:使用文本界面
这里是一个例子,使用文本界面.图形界面足够的用途,所以你不可能使用文本界面.然而,看一看,现有的算法列表,以下.
##加载数据集
>>负荷数据/云
>>谁
名称的大小字节级
distribution_parameters欧盘1464结构数组
模式2x500080000双阵列
目标1x500040000双阵列
总计为15076个元素使用121464个字节
数据集存储在变量中,模式和目标.
##选择试验方法,训练数据和测试数据
%使画根据错误的选择方法
>>=长度(目标);
%=20;
[test_indices,train_indices]=make_a_draw(楼(%/100 *我),我);
train_patterns=模式(train_indices:,);
train_targets=目标(:,train_indices);
test_patterns=模式(test_indices:,);
test_targets=目标(:,test_indices);
##选择分类器.找出参数使用帮助
>>帮助nearest_neighbor
利用最近邻算法分类
输入:
train_patterns-训练模式
train_targets-训练目标
test_patterns-测试模式
最近邻-邻居数
输出
test_targets-预测目标
##建立分类和分类数据
>>test_out=nearest_neighbor(train_patterns,train_targets,test_patterns,3);
##估计误差
>>=平均(test_targets~=test_out)
误差=
0.1313