MATLAB实现波士顿房价预测使用BP神经网络
MATLAB实现波士顿房价预测,使用BP神经网络
代码如下(包括下载数据和训练网络):
%%Download Housing Prices
filename = 'housing.txt';
%下载
urlwrite('http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data',filename);
%指定名字
inputNames = {'CRIM','ZN','INDUS','CHAS','NOX','RM','AGE','DIS','RAD','TAX','PTRATIO','B','LSTAT'};
outputNames = {'MEDV'};
housingAttributes = [inputNames,outputNames];
%%Import Data
%格式规范
formatSpec = '%8f%7f%8f%3f%8f%8f%7f%8f%4f%7f%7f%7f%7f%f%[^\n\r]';
fileID = fopen(filename,'r');
%读取大文件,比起testread方便
dataArray = textscan(fileID, formatSpec, 'Delimiter', '', 'WhiteSpace