I am trying to perform mutual information regression on the Kaggle Houses dataset. However, I get an error when I run mutual_info_regression. I am getting the error:
ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required.
X = home_data
X['LotFrontage'] = X['LotFrontage'].fillna(0)
X['MasVnrArea'] = X['MasVnrArea'].fillna(0)
X['GarageYrBlt'] = X['GarageYrBlt'].fillna(X['GarageYrBlt'].median())
X['SalePrice'].dropna(inplace=True)
y = X.pop('SalePrice')
for colname in X.select_dtypes("object"):
X[colname], _ = X[colname].factorize()
discrete_features = X.dtypes == int
from sklearn.feature_selection import mutual_info_regression
def make_mi_scores(X, y, discrete_features):
mi_scores = mutual_info_regression(X, y, discrete_features=discrete_features)
mi_scores = pd.Series(mi_scores, name="MI Scores", index=X.columns)
mi_scores = mi_scores.sort_values(ascending=False)
return mi_scores
mi_scores = make_mi_scores(X, y, discrete_features)
I've checked the shape of X, y, and discrete_features and they are of shape (1460, 80), (80,), and (1460,) respectively. Any help would be greatly appreciated.