了解Weka的代码
Understanding code of Weka
我正在研究machine learning book, written by Boštjan Kaluža, Pact publishing。
这里是代码的简要定义。
The code that aims to investigate the heating and cooling load
requirements of the buildings based on their construction
characteristics such as surface, wall and roof area, height, hazing
area, and compactness.The researchers used a simulator to design 12
different house configurations while varying 18 building
characteristics. Our first goal is to systematically analyze the
impact each building characterizes has on the target variable, that
is, heating or cooling load. We will use the linear regression
model for estimation. Linear regression model constructed a function
that linearly combines the input variables to estimate the heating
load.
下面的table显示了我们分析的数据:
代码如下:
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the path of the data file:");
String s = br.readLine();
// load CSV
CSVLoader loader = new CSVLoader();
loader.setSource(new File(s));
Instances data = loader.getDataSet();
//We will start with learning a model for heating load by setting the class
//attribute at the feature position
data.setClassIndex(data.numAttributes() - 1);
//The second target variable—cooling load—can be now removed:
Remove remove = new Remove();
remove.setOptions(new String[]{"-R", data.numAttributes()+""});
remove.setInputFormat(data);
data = Filter.useFilter(data, remove);
data.setClassIndex(data.numAttributes() - 1);
LinearRegression model = new LinearRegression();
model.buildClassifier(data);
System.out.println(model);
}
在代码中,我们删除了 "The second target variable—cooling load"。我想问的问题是,我们为什么要这样做?提前致谢。
输入x1到xn
y1 到 y2 是目标(输出)。
他们首先要对 x1 到 y1 进行线性回归,例如热负荷。这就是他们删除最后一个的原因。
很可能会有两个模型;一种用于预测热负荷,另一种用于预测冷负荷。原因是试图同时预测它们会导致多元回归,而不是线性回归。在线性回归中只有一个因变量。
我正在研究machine learning book, written by Boštjan Kaluža, Pact publishing。
这里是代码的简要定义。
The code that aims to investigate the heating and cooling load requirements of the buildings based on their construction characteristics such as surface, wall and roof area, height, hazing area, and compactness.The researchers used a simulator to design 12 different house configurations while varying 18 building characteristics. Our first goal is to systematically analyze the impact each building characterizes has on the target variable, that is, heating or cooling load. We will use the linear regression model for estimation. Linear regression model constructed a function that linearly combines the input variables to estimate the heating load.
下面的table显示了我们分析的数据:
代码如下:
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the path of the data file:");
String s = br.readLine();
// load CSV
CSVLoader loader = new CSVLoader();
loader.setSource(new File(s));
Instances data = loader.getDataSet();
//We will start with learning a model for heating load by setting the class
//attribute at the feature position
data.setClassIndex(data.numAttributes() - 1);
//The second target variable—cooling load—can be now removed:
Remove remove = new Remove();
remove.setOptions(new String[]{"-R", data.numAttributes()+""});
remove.setInputFormat(data);
data = Filter.useFilter(data, remove);
data.setClassIndex(data.numAttributes() - 1);
LinearRegression model = new LinearRegression();
model.buildClassifier(data);
System.out.println(model);
}
在代码中,我们删除了 "The second target variable—cooling load"。我想问的问题是,我们为什么要这样做?提前致谢。
输入x1到xn y1 到 y2 是目标(输出)。 他们首先要对 x1 到 y1 进行线性回归,例如热负荷。这就是他们删除最后一个的原因。
很可能会有两个模型;一种用于预测热负荷,另一种用于预测冷负荷。原因是试图同时预测它们会导致多元回归,而不是线性回归。在线性回归中只有一个因变量。