Trouble Calculating Exponential Value of a ColumnTransformerConstr Object
AnsweredHi,
I'm currently working on a project and encountered an issue while trying to calculate the exponential value of a ColumnTransformerConstr
object in Python. I would greatly appreciate any help or suggestions on how to resolve this problem.
Here's the code snippet I'm using:
pred_constr = add_predictor_constr(m, reg, m_feats, d)
pred_constr.print_stats()
exp_pred_constr = np.exp(pred_constr)
 AttributeError Traceback (most recent call last) AttributeError: 'ColumnTransformerConstr' object has no attribute 'exp' The above exception was the direct cause of the following exception: TypeError Traceback (most recent call last) <ipythoninput26c2e65d043cc1> in <cell line: 1>() > 1 exp_pred_constr = np.exp(pred_constr) TypeError: loop of ufunc does not support argument 0 of type ColumnTransformerConstr which has no callable exp method
It seems that the ColumnTransformerConstr
object does not have a builtin exp
method, preventing me from directly applying the np.exp()
function.
Could someone guide me on how to correctly calculate the exponential value of the specific attribute or value within the ColumnTransformerConstr
object? I want to obtain the exponential value for further computations.

Hi,
I am not sure what you want to do but the lines of codes that you show are not supposed to work.
The object `ColumnTransformerConstr` stores the data to embed a ColumnTransformer in a Gurobi model. That would be decision variables and constraints describing the column transformation. As such, it doesn't have values to which you could apply the exponential.
After the model is solved with Gurobi, you could apply `np.exp` to the values of the input variables or output variables. That would be using `np.exp(pred_constr.input_values())` (resp. `np.exp(pred_constr.output_values()`).
If you want to add to your model variables representing the exponential or logarithm of other variables, you should use general constraints (c.f. https://www.gurobi.com/documentation/10.0/refman/constraints.html#subsubsection:GenConstrFunction) to create those, but that's currently not done by Gurobi ML.
I hope this helps. If you have a more detailed description maybe I can tell you more precisely if it is doable.
Best regards,
Pierre
2
Please sign in to leave a comment.
Comments
1 comment