Skip to content

Instantly share code, notes, and snippets.

@mrkm4ntr
mrkm4ntr / BinaryLogisticRegression.scala
Created December 19, 2017 06:42
Minimal implementation of LogisticRegression in Spark ML
package org.apache.spark.ml.classification
import breeze.linalg.{DenseVector => BDV}
import breeze.numerics.sigmoid
import breeze.optimize.{CachedDiffFunction, DiffFunction, LBFGS}
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.ml.linalg.{BLAS, Vector, Vectors}
import org.apache.spark.ml.param.ParamMap
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.rdd.RDD
@mrkm4ntr
mrkm4ntr / RPN.scala
Last active August 29, 2015 14:21
Reverse Polish Notation with Scalaz
import scalaz._
import Scalaz._
object RPN {
type DoubleListState[A] = State[List[Double], A]
def eval(input: String) = {
def binOp(op: String): Option[(Double, Double) => Double] = op match {
case "+" => Some(_ + _)
case "-" => Some(_ - _)