econml/ortho_forest.py
def parameter_estimator_func(Y, T, X,
                                     nuisance_estimates,
                                     sample_weight=None):
            """Calculate the parameter of interest for points given by (Y, T) and corresponding nuisance estimates."""
            # Compute partial moments
            pointwise_params = DiscreteTreatmentOrthoForest._partial_moments(Y, T, nuisance_estimates)
            X_aug = PolynomialFeatures(degree=1, include_bias=True).fit_transform(X)
            # Compute coefficient by OLS on residuals
            if sample_weight is not None:
                weighted_X_aug = sample_weight.reshape(-1, 1) * X_aug
            else:
                weighted_X_aug = X_aug / X_aug.shape[0]
            # ell_2 regularization
            diagonal = np.ones(X_aug.shape[1])
            diagonal[0] = 0
            reg = lambda_reg * np.diag(diagonal)
            # Ridge regression estimate
            param_estimate = np.linalg.lstsq(np.matmul(weighted_X_aug.T, X_aug) + reg,
                                             np.matmul(weighted_X_aug.T, pointwise_params), rcond=None)[0].flatten()
            # Parameter returned by LinearRegression is (d_T, )
            return param_estimate
Calculate the parameter of interest for points given by (Y, T) and corresponding nuisance estimates.
Calculate the parameter of interest for points given by (Y, T) and corresponding nuisance estimates.
Calculate the parameter of interest for points given by ( Y T ) and corresponding nuisance estimates .
def parameter_estimator_func(Y, T, X,
                                     nuisance_estimates,
                                     sample_weight=None):
            pointwise_params = DiscreteTreatmentOrthoForest._partial_moments(Y, T, nuisance_estimates)
            X_aug = PolynomialFeatures(degree=1, include_bias=True).fit_transform(X)
            if sample_weight is not None:
                weighted_X_aug = sample_weight.reshape(-1, 1) * X_aug
            else:
                weighted_X_aug = X_aug / X_aug.shape[0]
            diagonal = np.ones(X_aug.shape[1])
            diagonal[0] = 0
            reg = lambda_reg * np.diag(diagonal)
            param_estimate = np.linalg.lstsq(np.matmul(weighted_X_aug.T, X_aug) + reg,
                                             np.matmul(weighted_X_aug.T, pointwise_params), rcond=None)[0].flatten()
            return param_estimate
def parameter_estimator_func ( Y , T , X , nuisance_estimates , sample_weight = None ) : pointwise_params = DiscreteTreatmentOrthoForest . _partial_moments ( Y , T , nuisance_estimates ) X_aug = PolynomialFeatures ( degree = 1 , include_bias = True ) . fit_transform ( X ) if sample_weight is not None : weighted_X_aug = sample_weight . reshape ( - 1 , 1 ) * X_aug else : weighted_X_aug = X_aug / X_aug . shape [ 0 ] diagonal = np . ones ( X_aug . shape [ 1 ] ) diagonal [ 0 ] = 0 reg = lambda_reg * np . diag ( diagonal ) param_estimate = np . linalg . lstsq ( np . matmul ( weighted_X_aug . T , X_aug ) + reg , np . matmul ( weighted_X_aug . T , pointwise_params ) , rcond = None ) [ 0 ] . flatten ( ) return param_estimate
Calculate the parameter of interest for points given by (Y, T) and corresponding nuisance estimates.
Calculate the parameter of interest for points given by ( Y T ) and corresponding nuisance estimates .
"""Calculate the parameter of interest for points given by (Y, T) and corresponding nuisance estimates.""" # Compute partial moments # Compute coefficient by OLS on residuals # ell_2 regularization # Ridge regression estimate # Parameter returned by LinearRegression is (d_T, )
Y
T
X
nuisance_estimates
sample_weight