title: Adding interaction effects to a random forest model at scikit-learn
body: <p>I am running a random forest regression model, but my results are not that great. One person recommended to check interaction effects.</p>
  <p>Surprisingly I do not see too many questions about this. <a href="https://stackoverflow.com/questions/45828964/how-to-add-interaction-term-in-python-sklearn">This one</a> did not help me. I am also not sure how to incorporate to my code <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PolynomialFeatures.html" rel="nofollow noreferrer">sklearn.preprocessing.PolynomialFeatures</a>.</p>
  <p>My data is very simple:</p>
  <p><a href="https://i.stack.imgur.com/VNrTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VNrTb.png" alt="" /></a></p>
  <p>My code:</p>
  <pre><code># Split data
  y = starbucks_log.iloc[:, 0]
  
  # x as all others 
  X = starbucks_log.drop('total_amount', axis = 1)
  
  # Set seed for reproducibility
  SEED = 1
  
  # Split dataset into 80% train and 20% test
  X_train, X_test, y_train, y_test = \
  train_test_split(X, y,
  test_size = 0.2,
  random_state = SEED)
  
  # Instantiate a random forests regressor 'rf' 400 estimators
  rf = RandomForestRegressor(n_estimators = 400,
  min_samples_leaf = 1,
  random_state = SEED)
  
  # Fit 'rf' to the training set
  rf.fit(X_train, y_train)
  # Predict the test set labels 'y_pred'
  y_pred = rf.predict(X_test)
  y_pred_train=rf.predict(X_train)
  # Evaluate the test set RMSE
  rmse_test = MSE(y_test, y_pred)**(1/2)
  rmse_train = MSE(y_train, y_pred_train)**(1/2)
  # Print the test set RMSE
  print('Test set RMSE of rf: {:.5f}'.format(rmse_test))
  print('Train set RMSE of rf: {:.5f}'.format(rmse_train))
  </code></pre>
  <p>I would like to add all possible interaction effects of <code>income</code>, <code>age</code>, and <code>male(gender)</code>. It would be easier to drop some of them later.</p>
  <p>Thanks!</p>