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
import scala.util.Random | |
object Bootstrap { | |
def generate[T](seed: T, numBootStraps: Int): Iterator[Int] = { | |
val rng = new Random(seed.hashCode()) | |
(0 until numBootStraps) | |
.toIterator | |
.map(_ => samplePoisson(rng, 1.0)) | |
} |
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
package me.invkrh.raft.core | |
import akka.actor.{Actor, ActorSystem, Props} | |
case class Holder(arr: Array[Int]) | |
class AddrChecker extends Actor { | |
override def receive: Receive = { | |
case h: Holder => | |
println("In: " + h.toString) |
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
// below Q1 – 1.5 × IQR or above Q3 + 1.5 × IQR | |
val yieldUplift = deltaDF.select("delta_exploit_relative_yield_uplift").collect().map(_.getDouble(0)).toList.sorted | |
def getMedian(sorted: List[Double]): Double = { | |
val len = sorted.size | |
if (len % 2 == 0) { | |
(sorted(len / 2 - 1) + sorted(len / 2)) / 2 | |
} else { | |
sorted(len / 2) |
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
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.util.{Failure, Success} | |
object Test extends App { | |
println("1 " + Thread.currentThread().getId) | |
try { | |
Future { | |
println("2 " + Thread.currentThread().getId) | |
throw new RuntimeException() |
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
import breeze.linalg.{det, DenseMatrix} | |
import org.apache.spark.mllib.linalg.{Matrices, Vectors} | |
import org.apache.spark.mllib.stat.distribution.MultivariateGaussian | |
object GaussianTest extends App { | |
val x = Vectors.dense(2.1, 3.1, 3.9) | |
val mu = Vectors.dense(2, 3, 4) | |
val sigma = | |
Matrices.dense(3, 3, Array(1.0, 0.0, 3.0, 0.0, 0.0, 0.0, 3.0, 0.0, 11.0).map(_ + 0.0001)) |
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
package fr.leboncoin.botdet.job.offline | |
object Test extends App { | |
implicit class IntOps(x: Int) { | |
def **(p: Int): Int = (1 to p).foldLeft(1) { | |
case (acc, elem) => acc * x | |
} | |
} |
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
# Example .scalafmt, comments are supported. | |
style = default | |
maxColumn = 100 | |
docstrings = JavaDoc | |
continuationIndent.defnSite = 2 | |
continuationIndent.callSite = 2 |
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
def mergeSort(input: Array[Int]): Array[Int] = { | |
if (input.size == 1) { | |
input | |
} else { | |
val mid = input.size / 2 | |
val (left, right) = input.splitAt(mid) | |
merge(mergeSort(left), mergeSort(right)) | |
} | |
} | |
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
package fr.leboncoin.ad2vec | |
import org.apache.spark.ml.feature.Word2VecModel | |
import org.apache.spark.ml.linalg.Vector | |
import org.apache.spark.rdd.RDD | |
import org.apache.spark.sql.{DataFrame, Row, SparkSession} | |
import org.apache.spark.sql.functions._ | |
import org.apache.spark.unsafe.hash.Murmur3_x86_32._ | |
import org.apache.spark.unsafe.types.UTF8String |
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
val i = 164545 | |
val weights = new SparseArray[Double](Array(164545, 3657, 165734), | |
Array(1.0d, 2.0d, 3.0d), 3, 262144, 0d | |
) | |
val res = weights.apply(i) |