การปรับมากเกินไป การทำให้สม่ำเสมอ และการหยุดใช้ก่อนกำหนด
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ต่างจาก Random Forest ตรงที่ Gradient Boosted Tree อาจปรับให้พอดีมากเกินไป ดังนั้น คุณจึงใช้การปรับให้เหมาะสมและการหยุดทำงานก่อนเวลาอันควรได้โดยใช้ชุดข้อมูลที่ใช้ตรวจสอบสำหรับเครือข่ายประสาทเทียม
ตัวอย่างเช่น รูปภาพต่อไปนี้แสดงเส้นโค้งความสูญเสียและความแม่นยำสำหรับชุดข้อมูลการฝึกและชุดข้อมูลที่ใช้ตรวจสอบเมื่อฝึกโมเดล GBT โปรดสังเกตว่าเส้นโค้งมีความแตกต่างกันมาก ซึ่งบ่งชี้ว่ามีการประมาณมากเกินไปในระดับสูง

รูปที่ 29 อัตราผลขาดทุนเทียบกับจํานวนแผนผังการตัดสินใจ

รูปที่ 30 ความแม่นยำเทียบกับจํานวนต้นไม้การตัดสินใจ
พารามิเตอร์การถ่วงน้ำหนักทั่วไปสำหรับต้นไม้ที่เพิ่มประสิทธิภาพด้วย Gradient มีดังนี้
- ความลึกสูงสุดของแผนผัง
- อัตราการหดตัว
- อัตราส่วนของแอตทริบิวต์ที่ทดสอบในแต่ละโหนด
- สัมประสิทธิ์ L1 และ L2 ของความเสียหาย
โปรดทราบว่าโดยทั่วไปแล้ว ต้นไม้การตัดสินใจจะเติบโตได้น้อยกว่าโมเดล Random Forest มาก โดยค่าเริ่มต้น ต้นไม้ที่มีการเพิ่มประสิทธิภาพด้วย Gradient ใน TF-DF จะเติบโตเป็นระดับความลึก 6
เนื่องจากต้นไม้มีความลึกไม่มาก จำนวนตัวอย่างขั้นต่ำต่อใบจึงมีผลกระทบเพียงเล็กน้อยและโดยทั่วไปจะไม่ได้รับการปรับแต่ง
ความจำเป็นในการใช้ชุดข้อมูลการตรวจสอบจะกลายเป็นปัญหาเมื่อจำนวนตัวอย่างการฝึกมีน้อย ดังนั้น การฝึกต้นไม้เพิ่มประสิทธิภาพด้วยอนุพันธ์ภายในลูปการทดสอบไขว้หรือปิดใช้การหยุดทำงานก่อนเวลาอันควรเมื่อทราบว่าโมเดลไม่ได้ปรับให้พอดีมากเกินไปจึงเป็นเรื่องปกติ
ตัวอย่างการใช้งาน
ในบทก่อนหน้า เราได้ฝึกโมเดล Random Forest กับชุดข้อมูลขนาดเล็ก ในตัวอย่างนี้ เราจะแทนที่โมเดล Random Forest ด้วยโมเดลต้นไม้ที่มีการเพิ่มประสิทธิภาพด้วย Gradient
model = tfdf.keras.GradientBoostedTreesModel()
# Part of the training dataset will be used as validation (and removed
# from training).
model.fit(tf_train_dataset)
# The user provides the validation dataset.
model.fit(tf_train_dataset, validation_data=tf_valid_dataset)
# Disable early stopping and the validation dataset. All the examples are
# used for training.
model.fit(
tf_train_dataset,
validation_ratio=0.0,
early_stopping="NONE")
# Note: When "validation_ratio=0", early stopping is automatically disabled,
# so early_stopping="NONE" is redundant here.
การใช้งานและข้อจำกัด
ต้นไม้ที่มีการเพิ่มประสิทธิภาพด้วย Gradient มีทั้งข้อดีและข้อเสีย
ข้อดี
- เช่นเดียวกับต้นไม้การตัดสินใจ รูปแบบนี้รองรับฟีเจอร์ที่เป็นตัวเลขและเชิงหมวดหมู่โดยกำเนิด และมักไม่จําเป็นต้องประมวลผลฟีเจอร์ล่วงหน้า
- ต้นไม้เพิ่มประสิทธิภาพด้วย Gradient มีไฮเปอร์พารามิเตอร์เริ่มต้นที่มักให้ผลลัพธ์ที่ยอดเยี่ยม อย่างไรก็ตาม การปรับแต่งไฮเปอร์พารามิเตอร์เหล่านั้นจะช่วยปรับปรุงโมเดลได้อย่างมาก
- โดยทั่วไปแล้ว โมเดลต้นไม้ที่เพิ่มประสิทธิภาพด้วย Gradient Boosting จะมีขนาดเล็ก (จำนวนโหนดและหน่วยความจำ) และทำงานได้เร็ว (มักจะใช้เวลาเพียง 1-2 µs / ตัวอย่าง)
ข้อเสีย
- ต้องฝึกต้นไม้การตัดสินใจตามลําดับ ซึ่งอาจทําให้การฝึกช้าลงอย่างมาก อย่างไรก็ตาม การที่ต้นไม้การตัดสินใจมีขนาดเล็กลงก็ช่วยลดความช้าในการฝึกได้บ้าง
- เช่นเดียวกับ Random Forest ต้นไม้เพิ่มประสิทธิภาพด้วยอนุพันธ์จะไม่สามารถเรียนรู้และใช้การนําเสนอภายในซ้ำได้ ต้นไม้การตัดสินใจแต่ละต้น (และแต่ละสาขาของต้นไม้การตัดสินใจแต่ละต้น) ต้องเรียนรู้รูปแบบชุดข้อมูลอีกครั้ง ในชุดข้อมูลบางชุด โดยเฉพาะชุดข้อมูลที่มีข้อมูลที่ไม่มีโครงสร้าง (เช่น รูปภาพ ข้อความ) จะทำให้ Gradient Boosted Tree แสดงผลลัพธ์ได้แย่กว่าวิธีการอื่นๆ
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-02-25 UTC
[null,null,["อัปเดตล่าสุด 2025-02-25 UTC"],[[["\u003cp\u003eGradient boosted trees, unlike random forests, are susceptible to overfitting and may require regularization and early stopping techniques using a validation dataset.\u003c/p\u003e\n"],["\u003cp\u003eKey regularization parameters for gradient boosted trees include maximum tree depth, shrinkage rate, attribute test ratio at each node, and L1/L2 coefficients on the loss.\u003c/p\u003e\n"],["\u003cp\u003eGradient boosted trees offer advantages such as native support for various feature types, generally good default hyperparameters, and efficient model size and prediction speed.\u003c/p\u003e\n"],["\u003cp\u003eTraining gradient boosted trees involves sequential tree construction, potentially slowing down the process, and they lack the ability to learn and reuse internal representations, potentially impacting performance on certain datasets.\u003c/p\u003e\n"]]],[],null,["# Overfitting, regularization, and early stopping\n\n\u003cbr /\u003e\n\nUnlike random forests, gradient boosted trees *can* overfit. Therefore, as for\nneural networks, you can apply regularization and early stopping using a\nvalidation dataset.\n\nFor example, the following figures show loss and accuracy curves for training\nand validation sets when training a GBT model. Notice how divergent the curves\nare, which suggests a high degree of overfitting.\n\n**Figure 29. Loss vs. number of decision trees.**\n\n**Figure 30. Accuracy vs. number of decision trees.**\n\nCommon regularization parameters for gradient boosted trees include:\n\n- The maximum depth of the tree.\n- The shrinkage rate.\n- The ratio of attributes tested at each node.\n- L1 and L2 coefficient on the loss.\n\nNote that decision trees generally grow much shallower than random forest\nmodels. By default, gradient boosted trees trees in TF-DF are grown to depth 6.\nBecause the trees are shallow, the minimum number of examples per leaf has\nlittle impact and is generally not tuned.\n\nThe need for a validation dataset is an issue when the number of training\nexamples is small. Therefore, it is common to train gradient boosted trees\ninside a cross-validation loop, or to disable early stopping when the model\nis known not to overfit.\n\nUsage example\n-------------\n\nIn the previous chapter, we trained a random forest on a small dataset. In this\nexample, we will simply replace the random forest model with a gradient boosted\ntrees model: \n\n model = tfdf.keras.GradientBoostedTreesModel()\n\n # Part of the training dataset will be used as validation (and removed\n # from training).\n model.fit(tf_train_dataset)\n\n # The user provides the validation dataset.\n model.fit(tf_train_dataset, validation_data=tf_valid_dataset)\n\n # Disable early stopping and the validation dataset. All the examples are\n # used for training.\n model.fit(\n tf_train_dataset,\n validation_ratio=0.0,\n early_stopping=\"NONE\")\n # Note: When \"validation_ratio=0\", early stopping is automatically disabled,\n # so early_stopping=\"NONE\" is redundant here.\n\nUsage and limitations\n---------------------\n\nGradient boosted trees have some pros and cons.\n\n**Pros**\n\n- Like decision trees, they natively support numerical and categorical features and often do not need feature pre-processing.\n- Gradient boosted trees have default hyperparameters that often give great results. Nevertheless, tuning those hyperparameters can significantly improve the model.\n- Gradient boosted tree models are generally small (in number of nodes and in memory) and fast to run (often just one or a few µs / examples).\n\n**Cons**\n\n- The decision trees must be trained sequentially, which can slow training considerably. However, the training slowdown is somewhat offset by the decision trees being smaller.\n- Like random forests, gradient boosted trees can't learn and reuse internal representations. Each decision tree (and each branch of each decision tree) must relearn the dataset pattern. In some datasets, notably datasets with unstructured data (for example, images, text), this causes gradient boosted trees to show poorer results than other methods."]]