Complete the code to create a new feature by multiplying two existing features.
df['interaction'] = df['feature1'] [1] df['feature2']
Multiplying two features creates an interaction feature that captures combined effects.
Complete the code to create interaction features for all pairs of columns in the DataFrame.
from itertools import combinations for col1, col2 in combinations(df.columns, 2): df[f'{col1}_x_{col2}'] = df[col1] [1] df[col2]
Multiplying pairs of features creates interaction terms that capture combined effects.
Fix the error in the code to correctly create an interaction feature between 'age' and 'income'.
df['age_income_interaction'] = df['age'] [1] df['income']
The interaction feature should multiply 'age' and 'income' to capture their combined effect.
Fill both blanks to create a dictionary of interaction features for words longer than 3 characters.
interaction_dict = {word: len(word) [1] 2 for word in words if len(word) [2] 3}The code squares the length of words longer than 3 characters.
Fill all three blanks to create a dictionary of interaction features where keys are uppercase words and values are their lengths if length is greater than 4.
interaction_features = [1]: [2] for word in words if len(word) [3] 4}
The dictionary maps uppercase words to their lengths for words longer than 4 characters.