How to use prediction model after onehot encoding? I have created a prediction model for this dataset
&gt;&gt;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

&gt;&gt;df.shape
(998,4)

&gt;&gt;X = df.iloc[:,:-1]
&gt;&gt;y = df.iloc[:,-1].values
&gt;&gt;from sklearn.compose import ColumnTransformer 
&gt;&gt;ct = ColumnTransformer([(&quot;cat&quot;, OneHotEncoder(),[0])], remainder=&quot;passthrough&quot;)
&gt;&gt;X = ct.fit_transform(X)  
&gt;&gt;x = X.toarray()
&gt;&gt;x = x[:,1:]

&gt;&gt;x.shape
(998,339)

&gt;&gt;from sklearn.ensemble import RandomForestRegressor
&gt;&gt;rf_model = RandomForestRegressor(random_state = 1)
&gt;&gt;rf_model.fit(x,y)

How can I use this model to predict Hours for user input in this format [[&quot;SDE&quot;, 90, 3]]
I tried
&gt;&gt;test_input = [[&quot;SDE&quot;, 90, 3]]
&gt;&gt;test_input = ct.fit_transform(test_input)  
&gt;&gt;test_input = test_input[[:,1:]

&gt;&gt;test_input[0]
array([24, 1], dtype=object)


&gt;&gt;predict_hours = rf_model.predict(test_input)
ValueError

Since my dataset has many categorical values its not possible enter the encoded value of &quot;SDE&quot; as input, I need to convert &quot;SDE&quot; to onehot encoded format after receiving the input [[&quot;SDE&quot;, 90, 3]]
I don't know how to do it can anyone help?
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)