How to use prediction model after onehot encoding?
from sklearn.compose import ColumnTransformer 
from sklearn.pipeline import Pipeline
from sklearn.ensemble import RandomForestRegressor

df.head()

    Service    Tasks Difficulty     Hours
0   ABC         24     1           0.833333
1   CDE         77     1           1.750000
2   SDE         90     3           3.166667
3   QWE         47     1           1.083333
4   ASD         26     3           1.000000

df.shape
(998,4)

X = df.drop([&quot;Hours&quot;],axis = 1)
y = df.Hours

ct = ColumnTransformer([(&quot;cat&quot;, OneHotEncoder(handle_unknown = &quot;ignore&quot;),[0])], remainder=&quot;passthrough&quot;)
    

rf_model = RandomForestRegressor(random_state = 1)

model = Pipeline([(&quot;preprocessing&quot;,ct),(&quot;model&quot;,rf_model)]).fit(X,y)

x_test = pd.DataFrame({&quot;Service&quot;:&quot;SDE&quot;, &quot;Tasks&quot;:90, &quot;Difficulty&quot;:3}, index = [0])

# Ideally you split your data into train and test,in this case you need to pass x_test that is a pandas dataframe with the values you want to predict
model.predict(x_test)