Importing XGBoost is the first step to using this machine learning library in your Python scripts or notebooks.
Fortunately, importing XGBoost is a straightforward process that only requires a single line of code.
import xgboost
Or, alternately:
import xgboost as xgb
By convention, many developers alias the xgboost
package as xgb
when importing.
This provides a shorter, more convenient name to reference when using XGBoost’s functions and classes throughout your code. However, using the alias is optional, and you can simply use import xgboost
if you prefer.
If the import fails, double-check that XGBoost is installed and that you’re running the import in the correct environment.