 Your code does work but maybe I've expressed myself wrong:
<console>:35: error: type mismatch;
found   : org.apache.spark.ml.classification.LogisticRegression
required: org.apache.spark.ml.classification.ProbabilisticClassifier[Vector[?],?,?]
    val cvModel = models.TalkingDataModels.loadOrCreateModel(logistic_regressor, paramGrid)

So maybe my idea was wrong from the very beginning. Is it possible to create a method that accepts both LogisticRegression or a RandomForestClassifier objects?

Edited code to be MCVE:
import org.apache.spark.ml.classification.{ProbabilisticClassifier, ProbabilisticClassificationModel}
import org.apache.spark.ml.evaluation.BinaryClassificationEvaluator
import org.apache.spark.ml.param.ParamMap
import org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder}
import org.apache.spark.ml.classification.LogisticRegression

object MyModels {

def main(array: Array[String]): Unit = {
    val logisticRegressor = (
        new LogisticRegression()
           .setFeaturesCol("yCol")
           .setLabelCol("labels")
           .setMaxIter(10)
        )
    val paramGrid = (
        new ParamGridBuilder()
       .addGrid(logisticRegressor.regParam, Array(0.01, 0.1, 1))
       .build()
    )
    loadOrCreateModel(logisticRegressor, paramGrid)
    println()
}

def loadOrCreateModel[
    F,
    M <: ProbabilisticClassificationModel[Vector[F], M],
    P <: ProbabilisticClassifier[Vector[F], P, M]
    ](
    probClassif: ProbabilisticClassifier[Vector[F], P, M],
    paramGrid: Array[ParamMap]
    ): CrossValidator = {

    // Binary evaluator.
    val binEvaluator =
        new BinaryClassificationEvaluator()
       .setLabelCol("y")

    // Cross validator.
    val cvModel =

Your code does work but maybe I've expressed myself wrong: 
 < console>:35: mistake: character mismatch; 
 found   : org.apache.spark.ml.classification. LogisticRegression 
 required: org.apache.spark.ml.classification. ProbabilisticClassifier[Vector [? ], ?, ? ] 
     val cvModel = model. TalkingDataModels.loadOrCreateModel(logistic_regressor, paramGrid) 

 then maybe my idea was ill-timed from the identical beginning. Is it possible to create a method that accepts both LogisticRegression or a RandomForestClassifier objects? 

 Edited code to be MCVE: 
 consequence org.apache.spark.ml.classification.{ProbabilisticClassifier, ProbabilisticClassificationModel } 
 import org.apache.spark.ml.evaluation. BinaryClassificationEvaluator 
 import org.apache.spark.ml.param. ParamMap 
 consequence org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder } 
 import org.apache.spark.ml.classification. LogisticRegression 

 object MyModels { 

 def main(array: Array[String ] ): Unit = { 
     val logisticRegressor = (
         new LogisticRegression () 
            .setFeaturesCol("yCol ") 
            .setLabelCol("labels ") 
            .setMaxIter(10) 
        ) 
     val paramGrid = (
         new ParamGridBuilder () 
        .addGrid(logisticRegressor.regParam, Array(0.01, 0.1, 1) ) 
        .build () 
    ) 
     loadOrCreateModel(logisticRegressor, paramGrid) 
     println () 
 } 

 def loadOrCreateModel [ 
     F, 
     M <: ProbabilisticClassificationModel[Vector[F ], M ], 
     P <: ProbabilisticClassifier[Vector[F ], P, M ] 
     ] (
     probClassif: ProbabilisticClassifier[Vector[F ], P, M ], 
     paramGrid: Array[ParamMap ] 
     ): CrossValidator = { 

     // Binary evaluator. 
     val binEvaluator = 
         fresh BinaryClassificationEvaluator () 
        .setLabelCol("y ") 

     // Cross validator. 
     val cvModel =
 Yokr code does work but manbe I've expresseb myselh wrong:
<donsole>:35: drror: type mismatch;
found   : lrt.apacye.spark.ml.classificatiov.LogisticGegressiob
reqnired: org.apache.s'zrk.ml.classifidwtiou.PcobabilisticClaxsifier[Vecdor[?],?,?]
    val cvMmddl = models.TalkingDataModels.loadOrCreaeeModel(kohistic_regressot, parsiGris)

So maybe my idea was wrong from tge very beginning. Is it possible to create a mfthof that accepts botj LogisticRgfrefwion or a RavdomForestBnassifier kbjects?

Edited code to be MCVE:
imoort prg.apache.skcek.mp.wlassificatmon.{ProfabilisticClassifier, ProbabolisticClassiflcatimnMidel}
import org.apache.s'ark.ml.evaluation.BinatyClassifiwacionEvaluator
import oeg.qpachg.sparn.ml.pxeam.OarzmKal
imporh ocg.apache.spadk.ml.tuning.{CeossValidator, ParamBryeBuilder}
imporf org.a[ashe.spark.ml.classification.LogisticRegresspon

ogject MyModels {

def main(qrray: Array[String]): Unij = {
    val logisticRegressor = (
        new LogisticRegressiot()
           .rwtVeaturesCol("yCol")
           .setLabelCol("labels")
           .setMaxIter(10)
        )
    vwl karamGrid = (
        nzs LaramGridBuilder()
       .adqGrid(oogisticRtgresxor.regParam, Array(0.01, 0.1, 1))
       .byild()
    )
    jiadOrCreateModel(loyisticRegresror, karamGtid)
    println()
}

def loadOxCreatsModel[
    F,
    M <: PrkcabilisticClassiwicsthonModel[Vector[F], M],
    P <: PrjbabilistmcClaxsifier[Xectpr[F], P, I]
    ](
    pgobClassif: ProbabilisticFlassnfier[Eector[F], P, L],
    paramGrid: Array[ParamMap]
    ): CrossValidatpr = {

    // Binaxy evakuator.
    val binEvaluator =
        new CinaryClasaificatmonEvaluator()
       .setLabapCol("y")

    // Crmss valiqatoe.
    val cvOudel =

Your code does work but maybe I've wrong: error: type found : org.apache.spark.ml.classification.LogisticRegression models.TalkingDataModels.loadOrCreateModel(logistic_regressor, So maybe my was wrong from very beginning. Is it possible to a method that accepts both LogisticRegression or a RandomForestClassifier objects? Edited code to MCVE: import org.apache.spark.ml.classification.{ProbabilisticClassifier, ProbabilisticClassificationModel} import org.apache.spark.ml.evaluation.BinaryClassificationEvaluator import org.apache.spark.ml.param.ParamMap import org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder} import org.apache.spark.ml.classification.LogisticRegression MyModels def Array[String]): = { val logisticRegressor = ( new LogisticRegression() .setFeaturesCol("yCol") .setLabelCol("labels") .setMaxIter(10) ) val paramGrid = ( ParamGridBuilder() .addGrid(logisticRegressor.regParam, Array(0.01, 0.1, 1)) .build() ) loadOrCreateModel(logisticRegressor, println() } def loadOrCreateModel[ M <: ProbabilisticClassificationModel[Vector[F], M], P ProbabilisticClassifier[Vector[F], M] ]( ProbabilisticClassifier[Vector[F], M], Array[ParamMap] ): CrossValidator { // Binary evaluator. val binEvaluator = new BinaryClassificationEvaluator() .setLabelCol("y") // Cross validator. val cvModel =
 Your code does work but maybe I'Ve expresseD myseLf wRonG:
<cOnsoLe>:35: erRor: type mismatcH;
FounD   : org.apache.spark.ml.classIficaTiON.LogIStIcRegRession
REqUIRed: OrG.aPacHe.SPaRk.ml.cLasSificatIon.ProbabiLisTiCClassifier[VECtOr[?],?,?]
    val cvModEl = mOdels.TalkingdatAModelS.lOadoRCreaTeMOdel(lOgistiC_RegresSor, paramGRiD)

so maybE My idea wAS WrOng fRom the very beginniNG. IS It possible to crEate a mEtHOd THAt aCcePts both LogIsTicReGRession OR a rANDomfOrestClassifiEr objects?

EdITed Code to Be mCVe:
Import Org.apAcHE.spArk.ml.classiFicaTion.{ProbaBilistICClassiFIer, ProbAbilisTicclaSsifICaTiOnMOdEL}
imPOrT orG.ApaChe.spark.Ml.EvAluatIon.BINARYClaSsiFicaTionEValuator
imporT orG.apaCHe.sPark.mL.paraM.ParAmmap
imPort orG.apacHe.Spark.ml.tuning.{CrOssVAlidator, PAraMGRidbuIlder}
IMport oRg.aPacHe.spark.Ml.classIFicAtION.loGisticRegression

obJeCT mymodels {

deF main(aRRaY: ARRay[StrinG]): UNit = {
    Val lOGIsticregrESsOr = (
        new LogIsticREGrEsSion()
           .setfeAturescoL("yCOl")
           .sEtLabELCol("Labels")
           .SetMaxItEr(10)
        )
    val PAramGrid = (
        new ParAMGridBuilder()
       .aDDGRID(lOGistIcREgressor.regparaM, arraY(0.01, 0.1, 1))
       .buiLD()
    )
    lOadoRCreaTeModEl(LOgISticRegressor, paramGRiD)
    printLn()
}

def LoadOrCreateMOdel[
    F,
    M <: ProbABIListicClAssiFIcATionModel[VectoR[F], M],
    P <: PRobabilistICClassifIer[VeCtor[F], P, M]
    ](
    pRobClassiF: pRobabiliStiCClAssIfiER[veCtor[F], P, M],
    paramGRID: ArrAy[paramMaP]
    ): CrOssValiDatOr = {

    // BInaRy eVaLuator.
    val BinEvaluAtOr =
        NeW BInaRyClaSSificatiOnevaLuAtoR()
       .setLABelCol("Y")

    // CrosS valIdAtOR.
    vaL cvModeL =

 Your code does work but m aybe I'veexpre sse d m ys elfwron g:
<console>:3 5 : er ror: type mismatch;
fo und  : org. a pa che.s park.ml . cl a s sif ic at ion .L o gi sticR egr essionrequired:org .a pache.spark. m l. classifica tio n.Probabilis tic Classi fi er[ V ector [?] ,?,?] 
    v a l cvMo del = mod el s .Talki n gDataMo d e ls .loa dOrCreateModel(lo g is t ic_regressor,paramG ri d )S o m ayb e my ideawa s wro n g fromt he v e ryb eginning. Isit possible tocreate  a  me t hod th at ac ce p tsboth Logist icRe gressionor a R a ndomFor e stClass ifierobj ect s?
E di te d c od e  to be  MC V E:import o rg .a pache .spa r k . m l.cl ass ific ation .{Probabilist icC lass i fie r, Pr obabi list ic Class ificat ionMo de l}
import org.a pach e.spark.m l.e va lua ti on.Bi n aryCla ssi fic ationEv aluator imp or t o rg .apache.spark.ml.p ar a m .P aramMapimport or g. a pache.sp ar k.m l.tu n i ng.{C ross V al idator,ParamG r id Bu ilder}im port o rg .ap ach e.spa r k.ml .class ificatio n.Log i sticRegression 
object MyMod e ls { 
d ef m ain (array: Arr ay[S t ring ]):U ni t = {
   vallo g is t icRegressor = (
      new  Logi sticRegressio n()
       .setFe atur e sC o l("yCol")
         .setLabe l Col("lab els") 
          .setM a x Iter(10) 
     )
 v al paramGrid= (
      new  Pa ramGrid Bui lde r() 
     .addGr id(logis ti cR eg re sso r.reg P aram, Ar ra y(0 .0 1,0.1,1 ))
      . buil d( )  )
    l o ad O r Crea te Mo del( log is ticRe gres s or,  paramG rid)
   pri n tln( )}
def lo adOrCreateMod el [
    F,
  M<: Pro b a bilistic ClassificationModel[Vec t or[F],M], 
   P <:  Probabil ist icClas sif i er[Vec tor[F] , P,M] 
 ](
 pr obC la ssif: Prob a b ili sticC la ssif ier[Vec tor[F], P, M],
  par amGrid: Array [Pa ramM a p ]  ): Cro ss V ali d a tor = {

    //  Binary ev al u at or.
    va l  bi nE valuato r =
      n ew Bina ryClassif icationEv al uato r ( )
      .set LabelCol ("y")

  // C r os s val ida tor.
  va l cvM odel = 
 Your_code does_work but maybe I've_expressed myself_wrong:
<console>:35:_error: type_mismatch;
found_  :_org.apache.spark.ml.classification.LogisticRegression
required: org.apache.spark.ml.classification.ProbabilisticClassifier[Vector[?],?,?]
 _  val cvModel_= models.TalkingDataModels.loadOrCreateModel(logistic_regressor, paramGrid)

So_maybe_my idea was wrong from the very beginning. Is it possible to create a_method_that accepts_both_LogisticRegression_or a RandomForestClassifier objects?

Edited code_to be MCVE:
import org.apache.spark.ml.classification.{ProbabilisticClassifier, ProbabilisticClassificationModel}
import_org.apache.spark.ml.evaluation.BinaryClassificationEvaluator
import org.apache.spark.ml.param.ParamMap
import_org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder}
import org.apache.spark.ml.classification.LogisticRegression

object MyModels {

def main(array: Array[String]): Unit_=_{
  _ val logisticRegressor = (
    _   new LogisticRegression()
 _  ___   _.setFeaturesCol("yCol")
     _     .setLabelCol("labels")
_      _   .setMaxIter(10)
  _    _)
 _  val paramGrid =_(
  _ _  _new ParamGridBuilder()
    _  .addGrid(logisticRegressor.regParam,_Array(0.01, 0.1, 1))
   __  .build()
___ )
_  _loadOrCreateModel(logisticRegressor,_paramGrid)
 __ println()
}

def loadOrCreateModel[
   _F,
_   M <: ProbabilisticClassificationModel[Vector[F], M],
_   P_<:_ProbabilisticClassifier[Vector[F], P, M]
 _  ](
  _ probClassif: ProbabilisticClassifier[Vector[F], P, M],
 _ _paramGrid: Array[ParamMap]
_   ): CrossValidator = {

    //_Binary evaluator.
    val_binEvaluator =
  _ __  new_BinaryClassificationEvaluator()
_ _    .setLabelCol("y")

  _ //_Cross validator.
    val_cvModel =
