DoubleMLBLP¶
doubleml_pyspark.utils.blp.DoubleMLBLP
¶
Best Linear Predictor (BLP) for DoubleML models.
This class fits and summarizes a best linear predictor for orthogonal signals and basis functions, typically used in Double Machine Learning workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis_columns
|
list of str
|
Names of the basis columns used as predictors. |
required |
target_column
|
str
|
Name of the orthogonal signal column. Default is |
'orth_signal'
|
is_gate
|
bool
|
Set to |
False
|
Methods:
| Name | Description |
|---|---|
confint |
Pointwise or joint confidence intervals for predicted CATE and GATE values. |
fit |
Fit the BLP. |
summary |
Summary for the best linear predictor effect after calling |
Attributes:
| Name | Type | Description |
|---|---|---|
basis_columns |
list[str]
|
The basis columns. |
blp_model |
Any
|
The BLP model. |
blp_omega |
ndarray | None
|
Coefficient covariance matrix of shape |
cov_type |
str | None
|
Covariance estimator used by the latest call to :meth: |
is_gate |
bool
|
Whether this BLP was built for GATE (dummy-basis) estimation. |
target_column |
str
|
The target/outcome column. |
Attributes¶
doubleml_pyspark.utils.blp.DoubleMLBLP.basis_columns
property
¶
The basis columns.
Returns:
| Type | Description |
|---|---|
list of str
|
The names of the basis columns. |
doubleml_pyspark.utils.blp.DoubleMLBLP.blp_model
property
¶
The BLP model.
Returns:
| Type | Description |
|---|---|
LinearRegression or None
|
The fitted PySpark LinearRegression model, or None if not fitted. |
doubleml_pyspark.utils.blp.DoubleMLBLP.blp_omega
property
¶
Coefficient covariance matrix of shape (d, d), populated after :meth:fit.
For cov_type='nonrobust' this is σ² · (XᵀX)⁻¹. For the HC
estimators it is the corresponding heteroskedasticity-consistent
sandwich covariance. The inversion uses the Moore-Penrose
pseudoinverse for rank-deficient or nearly collinear basis matrices.
doubleml_pyspark.utils.blp.DoubleMLBLP.cov_type
property
¶
Covariance estimator used by the latest call to :meth:fit.
doubleml_pyspark.utils.blp.DoubleMLBLP.is_gate
property
¶
Whether this BLP was built for GATE (dummy-basis) estimation.
doubleml_pyspark.utils.blp.DoubleMLBLP.target_column
property
¶
The target/outcome column.
Returns:
| Type | Description |
|---|---|
str
|
The name of the target column. |
Functions¶
doubleml_pyspark.utils.blp.DoubleMLBLP.confint
¶
confint(spark_session: SparkSessionType, basis: DataFrame | None = None, level: float = 0.95, joint: bool = False, n_rep_boot: int = 500) -> DataFrame
Pointwise or joint confidence intervals for predicted CATE and GATE values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spark_session
|
SparkSession
|
Active Spark session used to create the output DataFrame. |
required |
basis
|
DataFrame or None
|
Evaluation grid as a Spark DataFrame. Must contain all columns
listed in
|
None
|
level
|
float
|
Confidence level in |
0.95
|
joint
|
bool
|
If |
False
|
n_rep_boot
|
int
|
Number of bootstrap repetitions used to estimate the joint
critical value. Only relevant when |
500
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
plus a |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
TypeError
|
If |
ValueError
|
If |
doubleml_pyspark.utils.blp.DoubleMLBLP.fit
¶
Fit the BLP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame containing the basis and target columns. |
required |
cov_type
|
str
|
Covariance estimator. Supported values are |
'HC0'
|
use_persist
|
bool
|
Whether to cache the intermediate BLP DataFrame. Not supported on Databricks serverless compute. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DoubleMLBLP
|
The fitted instance. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If an unsupported covariance type is specified. |
doubleml_pyspark.utils.blp.DoubleMLBLP.summary
¶
Summary for the best linear predictor effect after calling fit.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with coefficients, standard errors, t-values, p-values, and confidence intervals for each basis column and the intercept. |