title: Multiple type for a variable in spark using scala
body: <p>I am working on a Spark project with scala. I want to train a model which can be k_means, gaussian_mixture, logistic regression, naive_bayes etc. But I cannot define a generic model as a return type. Since these algorithms' types are different like GaussianMixtureModel, KMeansModel etc. I cannot find any logical way to return this trained model.</p>
  
  <p>Here is a peace of code from the project:</p>
  
  <pre><code>model.model_algorithm match {
  
        case "k_means" =&gt;
  
          val model_k_means = k_means(data, parameters)
  
        case "gaussian_mixture" =&gt;
  
          val model_gaussian_mixture = gaussian_mixture(data, parameters)
  
        case "logistic_regression" =&gt;
  
          val model_logistic_regression = logistic_regression(data, parameters)  
  
  }
  </code></pre>
  
  <p>So is there a way to return this trained model or to define a generic model that accepts all types?</p>