# oobloss
袋外回归误差
函数库: TyMachineLearning
# 语法
ls = oobloss(mdl, Xnew, ynew)
# 说明
ls = oobloss(mdl,Xnew, ynew) 返回基于袋装模型mdl输入数据 Xnew 和响应值ynew 的袋外回归误差。
# 示例
训练袋装支持向量机模型
加载iris数据集。
using TyMachineLearning
using CSV
using DataFrames
file1 = joinpath(pkgdir(TyMachineLearning), "data/Regression/tree_x.csv")
file2 = joinpath(pkgdir(TyMachineLearning), "data/Regression/tree_y.csv")
fgdata_x = CSV.read(file1, DataFrame; header=0)
fgdata_y = CSV.read(file2, DataFrame; header=0)
fgdata_x1 = Matrix(fgdata_x)
fgdata_y1 = Array(fgdata_y)
X = DataFrame([fgdata_x1 fgdata_y1], :auto)
rename!(X, [:x4 => :y])
n_estimators = 10
learn_rate = 1.0
使用整个数据集训练袋装支持向量机模型。
mdl = AdaBoostrTree(X, n_estimators, learn_rate)
X_test = Array([[400, 100, 4000], [400, 130, 4000], [400, 150, 4000]])
res = TyMachineLearning.predict(mdl, X_test)
x_new, y_new = dropna(X)
ls = oobloss(mdl, x_new, y_new)
0.5509438470728792
# 输入参数
mdl - 预训练好的袋装模型Dataframe
预训练好的袋装模型对象。
数据类型: 对象
Xnew- 测试数据集矩阵
测试数据集。
数据类型: Matrix
ynew- 测试数据集响应值向量
测试数据集响应值。
数据类型: Vector
# 输出参数
ls - 输出值模型预测损失值
经过训练的袋装模型预测损失值。