मैट्रिक्स की ओर
आपने EducationField के छह अलग-अलग मान पहचाने हैं. लेकिन आपको लगता है कि जब आप मॉडल को नए डेटा पर चलाएँगे, तो अन्य मान भी आ सकते हैं. इसकी तैयारी के लिए, आप 50 टर्म्स वाला एक hash index बनाएँगे. textrecipes पैकेज, और attrition_train तथा attrition_test स्प्लिट पहले से लोड हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
R में Feature Engineering
अभ्यास निर्देश
- रेसिपी में ऐसा स्टेप जोड़ें जो
EducationFieldके लिए dummy_hash इंडेक्स जेनरेट करे. - रेसिपी को prepare करें.
- prepared रेसिपी को bake करें.
- baked रेसिपी टेबल और
EducationFieldवैल्यूज़ को एक टेबल में bind करें और पहले 7 रो प्रिंट करें, साथ ही कॉलम 1 और 18 से 20 भी.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
recipe <- recipe(~EducationField, data = attrition_train) %>%
# Add a step to the recipe that generates a dummy_hash index for EducationField
___(EducationField, prefix = NULL, signed = FALSE, num_terms = 50L)
# Prepare the recipe
object <- recipe %>%
___
# Bake the prepped recipe
baked <- ___(object, new_data = attrition_test)
# Bind the baked recipe table and the EducationField values into one table
bind_cols(___, baked)[1:7,c(1,18:20)]