title: Copy prediction model in python
body: <p>In my predictive python code</p>
  
  <p>I use the sklearn prediction model (KNN, RandomForest, LinearRegression, etc)</p>
  
  <p>in a loop as the loop try to find the best hyper-param optimization.</p>
  
  <p>once I find the best parameters I want to take a copy of the <strong>trained</strong> model</p>
  
  <p>How can I do that? </p>
  
  <pre><code>for k in range(1,10):
      knn = KNeighborsClassifier(n_neighbors=k)
      ...
      #some code to fit and train the model here and find the accuracy
      ...
      if accuracy &gt; top_accuracy:
           top_accuracy = accuracy
           top_knn = knn &lt;==== ?
  
  
  # code to fit top_knn with a new test dataset
  </code></pre>
  
  <p>does this copy the trained model with the trained, is there any way I can make sure that my model has trained data</p>