机器学习 属性_属性关系文件格式| 机器学习
機(jī)器學(xué)習(xí) 屬性
Today, we will be looking at the use of attribute relation file format for machine learning in java and we would be writing a small java code to convert the popularly used .csv file format into the arff (Attribute relation file format). This file format was developed by the computer science department of the University of Waikato, as the name suggests the file contains a list of attributes and one class attribute. The attribute relation file format is broadly divided into two portions:
今天,我們將研究在Java中使用屬性關(guān)系文件格式進(jìn)行機(jī)器學(xué)習(xí),并且我們將編寫一個(gè)小的Java代碼,將常用的.csv文件格式轉(zhuǎn)換為arff(屬性關(guān)系文件格式) 。 這種文件格式是由懷卡托大學(xué)計(jì)算機(jī)科學(xué)系開發(fā)的,顧名思義,該文件包含一個(gè)屬性列表和一個(gè)類屬性。 屬性關(guān)系文件格式大致分為兩部分:
Header field
標(biāo)頭字段
Data field
資料欄位
Now, we would be discussing these fields in detail,
現(xiàn)在,我們將詳細(xì)討論這些領(lǐng)域,
1) Header field
1)標(biāo)頭字段
The header field describes the name of the attributes, type of relation and their datatypes that are present in the data file the main difference between them .CSV and .arff file are that the in .CSV files you will find the values of the attributes just below their name but in .arff files, the name of the attributes are specified separately followed by the data which is present in a separate data field. The basic syntax for writing the attribute name In the header portion is as follows:
報(bào)頭字段描述了屬性,關(guān)系類型和數(shù)據(jù)類型存在于數(shù)據(jù)文件它們之間的主要區(qū)別.csv和.arff文件是中.CSV文件,你會(huì)發(fā)現(xiàn)值的屬性剛剛的名字在其名稱下方,但在.arff文件中,分別指定屬性名稱,后跟單獨(dú)數(shù)據(jù)字段中的數(shù)據(jù)。 在標(biāo)頭部分寫入屬性名稱的基本語(yǔ)法如下:
@attribute <attribute-name> <datatype>The image below shows an example of .arff file format,
下圖顯示了.arff文件格式的示例,
The following example is a data set contains the head-brain relation of the various users. From the picture above one can easily identify the number of attributes along with the type of data that they contain in our example all the data in all four attributes are in the form of number i.e. numeric. Apart from being numeric, the data type can be of the form of nominal, string type and data type specification.
下面的示例是一個(gè)數(shù)據(jù)集,其中包含各個(gè)用戶的頭顱關(guān)系。 從上面的圖片中,我們可以輕松地識(shí)別出屬性的數(shù)量以及它們所包含的數(shù)據(jù)類型,在我們的示例中,所有四個(gè)屬性中的所有數(shù)據(jù)都是數(shù)字即數(shù)字形式。 除了數(shù)字以外,數(shù)據(jù)類型還可以采用名義,字符串類型和數(shù)據(jù)類型規(guī)范的形式。
2) Data field
2)資料欄位
This field contains the data values of the attributes mentioned above in the attribute field these are the values will be used by our model to perform prediction and to determine the amount of accuracy that can be provided in the result of our model. The data present is separated by the comas under the heading of @data. The data as mentioned above in the attributes field can be as follows:
此字段包含屬性字段中上述屬性的數(shù)據(jù)值,這些值將由我們的模型用于執(zhí)行預(yù)測(cè)并確定可以在模型結(jié)果中提供的準(zhǔn)確度。 存在的數(shù)據(jù)在@data標(biāo)題下用逗號(hào)分隔。 上面在屬性字段中提到的數(shù)據(jù)可以如下:
Numerical
數(shù)值型
Nominal
標(biāo)稱
String
串
Date-time format
日期時(shí)間格式
The .CSV file, that I have used can be downloaded from here: headbrain7.csv
我使用過(guò)的.CSV文件可以從這里下載: headbrain7.csv
Below is the code is written in Java in eclipse IDE for converting the .CSV file into .arff file format make sure you have set the path to the weka.jar file if you haven’t, then just have a look at my previous article: Introduction to weka and Machine learning in Java
以下是在eclipse IDE中用Java編寫的代碼,用于將.CSV文件轉(zhuǎn)換為.arff文件格式,請(qǐng)確保已將weka.jar文件的路徑設(shè)置為,如果沒有,請(qǐng)看一下我的前一篇文章: Java中的weka和機(jī)器學(xué)習(xí)簡(jiǎn)介
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Code:
碼:
import java.io.File; import java.io.IOException;import weka.*; import weka.core.Instances; import weka.core.converters.ArffSaver; import weka.core.converters.CSVLoader;public class wekaapi {public static void main(String[] args) throws IOException {// load the CSV fileCSVLoader load = new CSVLoader();loader.setSource(new File("C:\\Users\\Logan\\Desktop\\ML\\linearregression\\headbrain.csv"));Instances data = load.getDataSet();//get instances objectArffSaver save = new ArffSaver();save.setInstances(data);//set the dataset we want to convertsave.setFile(new File("C:\\Users\\Logan\\Desktop\\ML\\headbrain.arff"));System.out.println("The .arff file format is as follows");save.writeBatch();System.out.println(data);}}Output
輸出量
Clean display and proper orientation of data make .arff files a popular choice among the data scientists for their analysis this was all for today guys, Hope you liked this article and stay tuned for more and have a great day ahead.
整潔的顯示和正確的數(shù)據(jù)方向使.arff文件成為數(shù)據(jù)科學(xué)家在分析中的普遍選擇,這對(duì)于今天的人來(lái)說(shuō)都是如此。希望您喜歡這篇文章,并繼續(xù)關(guān)注,以取得美好的一天。
翻譯自: https://www.includehelp.com/ml-ai/attribute-relation-file-format.aspx
機(jī)器學(xué)習(xí) 屬性
總結(jié)
以上是生活随笔為你收集整理的机器学习 属性_属性关系文件格式| 机器学习的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 0.1uf与47uf并联_UF是什么形式
- 下一篇: 2018php项目实战视频教程,2018