code: def autofit(ts, maxp=5, maxd=2, maxq=5, sc=None):
      
      assert sc != None, "Missing SparkContext"
      
      jmodel = sc._jvm.com.cloudera.sparkts.models.ARIMA.autoFit(_py2java(sc, Vectors.dense(ts)), maxp, maxd, maxq)
      return ARIMAModel(jmodel=jmodel, sc=sc)
docs: Utility function to help in fitting an automatically selected ARIMA model based on approximate
      Akaike Information Criterion (AIC) values. The model search is based on the heuristic
      developed by Hyndman and Khandakar (2008) and described in [[http://www.jstatsoft
      .org/v27/i03/paper]]. In contrast to the algorithm in the paper, we use an approximation to
      the AIC, rather than an exact value. Note that if the maximum differencing order provided
      does not suffice to induce stationarity, the function returns a failure, with the appropriate
      message. Additionally, note that the heuristic only considers models that have parameters
      satisfying the stationarity/invertibility constraints. Finally, note that our algorithm is
      slightly more lenient than the original heuristic. For example, the original heuristic
      rejects models with parameters "close" to violating stationarity/invertibility. We only
      reject those that actually violate it.
     
      This functionality is even less mature than some of the other model fitting functions here, so
      use it with caution.
     
      Parameters
      ----------
      ts:
          time series to which to automatically fit an ARIMA model as a Numpy array
      maxP:
          limit for the AR order
      maxD:
          limit for differencing order
      maxQ:
          limit for the MA order
      sc:
          The SparkContext, required.
      
      returns an ARIMAModel