Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generating scores using XGBoost The function get_margin_scores is used to predict the sector for each of the given samples. Input Training set (X_train) Validation set

Generating scores using XGBoost

The function get_margin_scores is used to predict the sector for each of the given samples.

Input

  1. Training set (X_train)
  2. Validation set (X_valid)
  3. Training labels (y_train)
  4. XGBoost Parameter List (param)

Output Return the following:

  1. y_pred_valid: The raw output scores for the validation set

Note:

  1. Round all raw scores to three decimal places
  2. Remember to use verbose_eval = False while training.
  3. Remember to provide the num_round parameter while training and do not change it. We have currently set it to 100 (Refer to previous cell). Not providing the parameter or changing it could produce different results.
  4. Documentation for XGBoost Python API is here

All but one of the lines of the function have been filled. You need only fill the one missing line that trains the model. Check the XGBoost documentation for instructions on using train() function for XGBoost

 
def get_margin_scores(X_train, X_valid, y_train, param):
 dtrain = xgb.DMatrix(X_train, label=y_train)
 evallist = [(dtrain, 'train')]
 plst = param.items()
 ###
 
 ### YOUR CODE HERE
 ###
 dvalid = xgb.DMatrix(X_valid)
 y_pred_valid = bst.predict(dvalid, ntree_limit=bst.best_ntree_limit, output_margin=True)
 y_pred_valid = np.around(y_pred_valid, decimals = 3)
 return y_pred_valid

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions