Non negative least square on some coefficient Non negative least square solves
$$
y = \alpha^T x \\
s.t. \forall i,~ \alpha_i \geq 0
$$
However, I would like to apply the non negativity constraint only on some coefficient, say only the $\alpha_i,~ \forall i \in \mathcal{S}$.
This is not possible using scipy's nnls function. However, I think I can solve the problem by using nnls with the following trick:
$$
y = \sum_{i \in \mathcal{S}} \alpha_i x_i + \sum_{i \notin \mathcal{S}} \beta_i x_i - \sum_{i \notin \mathcal{S}} \gamma_i x_i \\
s.t.~\forall i~, \alpha_i \geq 0, \beta_i \geq 0, \gamma_i \geq 0
$$
but this is hacky. Do you know any over way to implement this in python?

Your approach with the extra parameters will be problematic as multiple values for the coefficients will provide a same solution (the solution won't be unique).
Non-negative least squares regression is often solved by an active set method that updates in steps the active constraints (see for instance How do Lawson and Hanson solve the unconstrained least squares problem?). In those steps various regular least squares estimates are computed for different active sets. Those steps will fail with your approach because of the multiple solutions (you will get some errors during the computations like non-invertible matrices).
An alternative nnls for Python (aside from Galen's response) could be scipy.optimize.lsq_linear, which allows setting individual constraints and uses an active set method.
