회귀 앙상블 훈련시키기
이 예제에서는 carsmall
데이터에 대해 훈련된 자동차의 마력과 무게를 기반으로 자동차의 연비를 예측하는 회귀 앙상블을 만드는 방법을 보여줍니다.
carsmall
데이터 세트를 불러옵니다.
load carsmall
예측 변수 데이터를 준비합니다.
X = [Horsepower Weight];
응답 변수 데이터는 MPG
입니다. 유일하게 사용 가능한 부스팅 회귀 앙상블 유형은 LSBoost
입니다. 이 예제의 경우, 100개 트리의 앙상블을 임의로 선택하고 디폴트 트리 옵션을 사용합니다.
회귀 트리의 앙상블을 훈련시킵니다.
Mdl = fitrensemble(X,MPG,'Method','LSBoost','NumLearningCycles',100)
Mdl = RegressionEnsemble ResponseName: 'Y' CategoricalPredictors: [] ResponseTransform: 'none' NumObservations: 94 NumTrained: 100 Method: 'LSBoost' LearnerNames: {'Tree'} ReasonForTermination: 'Terminated normally after completing the requested number of training cycles.' FitInfo: [100x1 double] FitInfoDescription: {2x1 cell} Regularization: []
앙상블에서 첫 번째로 훈련된 회귀 트리의 그래프를 플로팅합니다.
view(Mdl.Trained{1},'Mode','graph');
기본적으로, fitrensemble
는 LSBoost에 대한 얕은 트리를 성장시킵니다.
마력이 150이고 무게가 2750lbs인 자동차의 연비를 예측합니다.
mileage = predict(Mdl,[150 2750])
mileage = 23.6713