In [29]:
// workaround to suppress verbose output of variables
implicit def dont_show_stuff[T] = new pprint.PPrinter[T] {
  def render0(t: T, c: pprint.Config) : Iterator[String] = List("[hidden]").toIterator
}
Out[29]:
defined function dont_show_stuff
In [30]:
import $ivy.`com.picnicml::doddle-model:0.0.0-SNAPSHOT`
import $ivy.`org.plotly-scala::plotly-jupyter-scala:0.3.0`
Out[30]:
import $ivy.$                                          

import $ivy.$                                             
In [31]:
import scala.util.Random
import breeze.linalg._
import com.picnicml.doddlemodel.data.{loadBreastCancerDataset, splitDataset, shuffleDataset}
import com.picnicml.doddlemodel.linear.LogisticRegression
import com.picnicml.doddlemodel.metrics.RankingMetrics.rocCurve
import com.picnicml.doddlemodel.metrics.auc
Out[31]:
import scala.util.Random

import breeze.linalg._

import com.picnicml.doddlemodel.data.{loadBreastCancerDataset, splitDataset, shuffleDataset}

import com.picnicml.doddlemodel.linear.LogisticRegression

import com.picnicml.doddlemodel.metrics.RankingMetrics.rocCurve

import com.picnicml.doddlemodel.metrics.auc
In [32]:
implicit val rand: Random = new Random(0)
val (x, y) = (shuffleDataset _).tupled(loadBreastCancerDataset)
val (xTr, yTr, xTe, yTe) = splitDataset(x, y, proportionTrain = 0.75)

val model = LogisticRegression().fit(xTr, yTr)
val roc = rocCurve(yTe, model.predictProba(xTe)(::, 0))
println(s"test set AUC: ${auc(yTe, model.predictProba(xTe)(::, 0))}")
test set AUC: 0.9962546816479401
Out[32]:
rand: Random = [hidden]
x: com.picnicml.doddlemodel.data.package.Features = [hidden]
y: com.picnicml.doddlemodel.data.package.Target = [hidden]
xTr: com.picnicml.doddlemodel.data.package.Features = [hidden]
yTr: com.picnicml.doddlemodel.data.package.Target = [hidden]
xTe: com.picnicml.doddlemodel.data.package.Features = [hidden]
yTe: com.picnicml.doddlemodel.data.package.Target = [hidden]
model: LogisticRegression = [hidden]
roc: com.picnicml.doddlemodel.metrics.RankingMetrics.RocCurve = [hidden]
In [33]:
import plotly._
import plotly.element._
import plotly.layout._
import plotly.JupyterScala._
plotly.JupyterScala.init()
Out[33]:
import plotly._

import plotly.element._

import plotly.layout._

import plotly.JupyterScala._
In [34]:
val xs = roc.fpr.toScalaVector
val ys = roc.tpr.toScalaVector

val scatter = Scatter(xs, ys, marker = Marker(color = Color.RGB(0, 102, 255)), fill = Fill.ToZeroY)
val layout = Layout(height = 650, width = 650)

Seq(scatter).plot(layout, "")
Out[34]:
xs: scala.package.Vector[Double] = [hidden]
ys: scala.package.Vector[Double] = [hidden]
scatter: Scatter = [hidden]
layout: Layout = [hidden]
res33_4: String = [hidden]