title: How to take a user input and pass that to a predictive model
body: <p>I have a dataframe on which I have built a predictive model. The data is divided to train and test, and I have used Randomforest classifier.</p>
  <p>Now, The user pass a new data, which needs to pass through this model and give the result.</p>
  <p>It is a text data, and below is the dataframe:</p>
  <pre><code>Description          Category
  Rejoin this domain   Network
  Laptop crashed       Hardware
  Installation Error   Software
  </code></pre>
  <p>Code :</p>
  <pre><code>############### Feature extraction ##############
  countvec = CountVectorizer()
  counts = countvec.fit_transform(read_data['Description'])
  df = pd.DataFrame(counts.toarray())
  df.columns = countvec.get_feature_names()
  print(df)
  
  ########## Join with original data ##############
  df = read_data.join(df)
  a = list(df.columns.values)
  
  ########## Creating the dependent variable class for &quot;Category&quot; variable ###########
  factor = pd.factorize(df['Category'])
  df.Category = factor[0]
  definitions = factor[1]
  print(df.Category.head())
  print(definitions)
  
  ########## Creating the dependent variable class for &quot;Description&quot; variable ###########
  factor = pd.factorize(df['Description'])
  df.Description = factor[0]
  definitions_1 = factor[1]
  print(df.Description.head())
  print(definitions_1)
  
  ######### Split into Train and Test data #######################
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.80, random_state = 21)
  
  ############# Random forest classification model #########################
  classifier = RandomForestClassifier(n_estimators = 10, criterion = 'entropy', random_state = 42)
  classifier.fit(X_train, y_train)
  
  ######### Predicting the Test set results ##############
  y_pred = classifier.predict(X_test)
  
  #####Reverse factorize (converting y_pred from 0s,1s and 2s to original class for &quot;Category&quot; ###############
  reversefactor = dict(zip(range(3),definitions))
  y_test = np.vectorize(reversefactor.get)(y_test)
  y_pred = np.vectorize(reversefactor.get)(y_pred)
  
  #####Reverse factorize (converting y_pred from 0s,1s and 2s to original class for &quot;Description&quot; ###############
  reversefactor = dict(zip(range(53),definitions_1))
  X_test = np.vectorize(reversefactor.get)(X_test)
  </code></pre>