Let $(X,Y)$ be two random variables. Suppose that the expectation function of $Y$ conditional on $X=x$ is \[ \operatorname {E}[Y | X = x] = g(x). \] Therefore the following derivative is well defined \[ \frac{d \operatorname {E}[Y | X = x]}{dx} = g'(x), \] and $g'(x)$ is the marginal change in the conditional expected value of $Y$ with respect of a small change in $x$.
The conditional expectation (as a random variable) of $Y$ conditional on $X$ is defined as \[ \operatorname {E}[Y | X] = g(X). \] Is the derivative with respect of the random variable $X$ \[ \frac{d \operatorname {E}[Y | X]}{dX} = g'(X), \] actually well defined? What is the difference between $g'(X)$ and $g'(x)$ ?