title: AttributeError: 'str' object has no attribute 'fit' - Pyspark
body: <p>I am trying to run the script below in PySpark3 and receiving the error message that follows. I am using this has something to do with formatting but I am not sure how to go about doing so. Any help would be much appreciated. </p>
  
  <pre><code>train,test = df.randomSplit([0.7,0.3])
  
  models = ["LinearRegression()","DecisionTreeRegressor()","RandomForestRegressor()","GBTRegressor()"]
  
  for model in models:
  
      # Fit our model
      M = model
      fitModel = M.fit(train)
  
      # Load the Summary
      trainingSummary = fitModel.summary
  
  #     trainingSummary.residuals.show()
      print("Training RMSE: %f" % trainingSummary.rootMeanSquaredError)
      print("Training r2: %f" % trainingSummary.r2)
  
  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-15-d0b941a7170e&gt; in &lt;module&gt;()
        8     # Fit our model
        9     M = model
  ---&gt; 10     fitModel = M.fit(train)
       11 
       12     # Load the Summary
  
  AttributeError: 'str' object has no attribute 'fit'
  </code></pre>