Closed craftsliu closed 2 months ago
when i ! = 0, it will raise the problems
@craftsliu thanks for reporting. While I see an opportunity to improve our code to capture cases like this, can I ask where does your df
or df_matched
come from? in case it's a public data source that i can easily reproduce your error.
UnboundLocalError Traceback (most recent call last) /tmp/ipykernel_3893757/880346473.py in () 2 p_model = ElasticNetPropensityModel() 3 ohe = OneHotEncoder(min_obs=df.shape[0] * 0.01) ----> 4 X_cat = ohe.fit_transform(df_matched[ENCODING_COLS]).todense() 5 X = np.hstack([df_matched[PROPENSITY_FEATURES].values, X_cat]) 6
~/anaconda3/envs/myenv/lib/python3.8/site-packages/causalml/features.py in fit_transform(self, X, y) 223 self.label_encoder.fit(X) 224 --> 225 return self.transform(X) 226 227
~/anaconda3/envs/myenv/lib/python3.8/site-packages/causalml/features.py in transform(self, X) 203 X_new = X_col 204 else: --> 205 X_new = sparse.hstack((X_new, X_col)) 206 207 logger.debug(
UnboundLocalError: local variable 'X_new' referenced before assignment Environment (please complete the following information):
pandas
,scikit-learn
,cython
): [e.g.pandas==1.3.5
,scikit-learn==1.0.2
,cython==0.29.34
]Additional context Add any other context about the problem here.