-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from atamborrino/typedML
Add TypedTransformer and TypedEstimator, towards a type-safe Spark ML API
- Loading branch information
Showing
22 changed files
with
1,173 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package frameless | ||
package ml | ||
|
||
import frameless.ops.SmartProject | ||
import org.apache.spark.ml.{Estimator, Model} | ||
|
||
/** | ||
* A TypedEstimator fits models to data. | ||
*/ | ||
trait TypedEstimator[Inputs, Outputs, M <: Model[M]] { | ||
val estimator: Estimator[M] | ||
|
||
def fit[T, F[_]](ds: TypedDataset[T])( | ||
implicit | ||
smartProject: SmartProject[T, Inputs], | ||
F: SparkDelay[F] | ||
): F[AppendTransformer[Inputs, Outputs, M]] = { | ||
implicit val sparkSession = ds.dataset.sparkSession | ||
F.delay { | ||
val inputDs = smartProject.apply(ds) | ||
val model = estimator.fit(inputDs.dataset) | ||
new AppendTransformer[Inputs, Outputs, M] { | ||
val transformer: M = model | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.