how to obtain the 'formula' of a ML classification model I have followed some tutorial for classification using xgboost, the tutorial usually finishes at predict using the model, and evaluate its accuracy.
My question is, how do I extract the 'equation' out from the model? 
In my example, it is a binary classification (1 or 0) from a feature list of 150 element, so I expect an equation of y = ax1 + bx2 + ... + zzzx150, or something similar, so I can actually use the model.
 A: If you are using the R interface, there is xgboostExplainer. 
xgboostExplainer outputs the contributions of the features to the predictions on a per-instance basis. In a binary classification task, for example, the prediction for an input vector $\left( x_1, x_2, \dots, x_M \right)$ is usually made based on a predicted "success" probability, $\hat{p}$:
$$
\hat{p} = \mathrm{sigmoid} \left( f_{1}\left(x_1\right) + f_{2}\left(x_2\right) + \dots + f_{M}\left(x_M\right) \right)
$$
For simple logistic regressions, $ f_{i}\left(x_i\right) $ is a linear function of $x_i$, i.e. $ f_{i}\left(x_i\right) = w_i x_i$ and so we will be able to extract and interpret the estimates for $w_1$. For boosting trees, however, the $f_i\left(x_i\right)$ is generally assumed to be non-linear, so there is no "coefficients" or "formula" like those found in generalised linear models to speak of; while the leaves of the trees do have scores/weights assigned to them, they are not very straightforward to interpret.
Given a trained xgboost model and an input vector, xgboostExplainer will tell you the values of the individual $f_{1}\left(x_1\right),\ f_{2}\left(x_2\right),\ \dots,\ f_{M}\left(x_M\right)$ for the said input. These can be interpreted as the "contributions" of each feature towards its final prediction. You may then interrogate the explanations produced for your predictions to understand the (non-linear) relationships learnt by the model. See this article for a nice exposition of this idea and the package's capabilities.
For the python API, there is the ELI5 package; I haven't used it myself but judging by its documentation it is similar to xgboostExplainer but covers many different types of models (including xgboost).
A: 
My question is, how do I extract the 'equation' out from the model

It all depends on the model you are using. Some models do not have a straighrforward formula you can extract, and are often called blackbox models. I presume you are looking for some form of interpretability of your model... Since you are using an XGBoost model then the answer is not straightforward. You could try the following: 


*

*Extract the first decision tree and use it as a basis for extracting some form of equation (in the shape of a decision tree) - but this won't be as useful as the decision tree from a standard decision tree model due to the bagging and boosting effect of XGboost

*Extract the weights of the different trees, and then compare it with the structure of the trees. But again you won't get any straightforward equation

*Compute the partial dependency plots for a particular feature (or interaction of features) 

A: 
In my example, it is a binary classification (1 or 0) from a feature
  list of 150 element, so I expect an equation of y = ax1 + bx2 + ... +
  zzzx150, or something similar, so I can actually use the model.

Your question is ill-posed. The "formula" like $Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \dots + \beta_k X_k + \varepsilon$ defines linear regression model, where $Y$ is a linear function of the features $X_1,X_2,\dots,X_k$. There is no such simple formula for other models. For most of the other machine learning models, we also use features to predict $Y$, so we have something like $Y = f(X)$, but $f$ is a much more complicated, non-linear function.
If you'd like to code the predict(X) method by hand, that returns the outputs matching what XGBoost returns, you'd need to go deeper into the literature and source code of the implementation of the package that you used (since there may be minor differences between the papers and different implementations). Next, you'd need to basically re-write the appropriate XGBoost method yourself. Unless you want to do this "to learn more about inner workings of XGBoost", or you need to translate the code to different language, so that it works on your infrastructure, this isn't something that you should do. Every such implementation has some kind of predict(X) method that already does what you want to achieve, you should find examples in the documentation.
For more details on XGBoost, check the tutorial in their documentation or this talk by Tianqi Chen.
