I'm trying to predict a value using a linear regression model. However, when I use .predict from sklearn I can't find a way to plug in the data for X without getting a data type error.
from sklearn import linear_model
KitchenQual_X = KitchenQual_df[["OverallQual", "YearBuilt", "YearRemodAdd", "GarageCars", "GarageArea"]]
KitchenQual_Y = KitchenQual_df["dummy_KitchenQual"]
regr_KitchenQual = linear_model.LinearRegression()
regr_KitchenQual.fit(KitchenQual_X, KitchenQual_Y)
print("Predicted missing KitchenQual value: " + regr_KitchenQual.predict(df_both[["OverallQual", "YearBuilt", "YearRemodAdd", "GarageCars", "GarageArea"]].loc[[1555]]))
When running the code in my kaggle notebook I receive the following error:
---------------------------------------------------------------------------
UFuncTypeError Traceback (most recent call last)
<ipython-input-206-1f022a48e21c> in <module>
----> 1 print("Predicted missing KitchenQual value: " + regr_KitchenQual.predict(df_both[["OverallQual", "YearBuilt", "YearRemodAdd", "GarageCars", "GarageArea"]].loc[[1555]]))
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U37'), dtype('<U37')) -> dtype('<U37')
I would appreciate any help :)
dtype('<U37')is a string, scikit can't handle strings. - Tgsmith61591