Comments (5)
I am sorry for the confusion.
Basically, Your understanding is totally correct. For this logistic regression 'objective=binary:logistic'. What we get is in preds not x_i, but a transformed version preds_i = 1 /(1+exp(-x_i)) . So taking first and second order derivatives to x_i gives you preds_i - y_i, and preds_i (1- preds_i).
A more understandable case, and I commented, is to leave objective as default, which will not have any transformation on prediction, you get x_i in preds, and the code should be modified to
prob = 1.0/(1+np.exp(-preds))
grads = prob - labels
hess = prob * (1-prob)
But you need to remember to transform prediction into prob if you want probability.
Hope this answers your question
from xgboost.
Thank you for the explanation!
So to summarize, if I would want to minimize my own loss function, I should set objective="binary:logitraw"
in order not to transform the preds variable entering my custom loss function, and supply a function which computes dL/dx_i and d^2L/dx_i^2 as the obj
parameter to xgboost.train
?
from xgboost.
Yes, exactly
On Tuesday, July 15, 2014, rmldj [email protected] wrote:
Thank you for the explanation!
So to summarize, if I would want to minimize my own loss function, I
should set objective="binary:logitraw" in order not to transform the
preds variable entering my custom loss function, and supply a function
which computes dL/dx_i and d^2L/dx_i^2 as the obj parameter to
xgboost.train?—
Reply to this email directly or view it on GitHub
https://github.com/tqchen/xgboost/issues/15#issuecomment-49014367.
Sincerely,
Tianqi Chen
Computer Science & Engineering, University of Washington
from xgboost.
so then the objective function is to left as "binary:logitraw", and then where do we pass in the custom loss function to the xgb model? I thought the custom loss function was to be set to the obj parameter?
from xgboost.
I have a question about this code too. when I run the code on my computer, the python shows the error: Kernel died, restarting, do you know how can i fix it?
user define objective function, given prediction, return gradient and second order gradient
def logregobj( preds, dtrain ):
labels = dtrain.get_label()
grad = preds - labels
hess = preds * (1.0-preds)
return grad, hess
from xgboost.
Related Issues (20)
- Latest version training crashes HOT 12
- Error when trying to build HOT 4
- Model provides different results for different Python versions HOT 2
- error in the docs for ranking HOT 1
- Defining a callback to write hessians of train observations to a csv file HOT 2
- Slow inference on sphoradic stremaing data HOT 2
- XGBoost GPU Warning When Working with BayesSearchCV (XGBoost is running on: cuda:0, while the input data is on: cpu.)
- help installing xgboost with gpu HOT 2
- Potential Documentation Inaccuracy Regarding Feature Interaction Constraints
- Horizontal Federated Learning with Secure Features RFC
- [bug] Python - Cuda error (without using Cuda) HOT 5
- Pandas 2.2: Index.format is deprecated
- ArrayInterface handler for cuDF DataFrame cannot yet handle Boolean columns HOT 1
- src/metric/auc.cc:322: Check failed: auc <= local_area HOT 1
- XGBoost4j-spark CrossValidation train FAILED on multi-GPU environment: : Multiple processes running on same CUDA device is not supported! HOT 1
- [jvm-packages] Scaladoc is not working in latest XGBoost
- [CI] Tracker for improving build and CI/CD infrastructure
- [CI] Set up a nightly pipeline to test with dev versions of RAPIDS
- xgboost predict takes a long time
- xgboost4j_2.12:1.7.6 's (ml/dmlc/xgboost4j/java/XGBoostJNI.XGBoosterPredict) much slower than 0.90 in some model HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xgboost.