Skip to content

Instantly share code, notes, and snippets.

View mandar2812's full-sized avatar
🏠
Working from home

Mandar Chandorkar mandar2812

🏠
Working from home
View GitHub Profile
@mandar2812
mandar2812 / MedianRecursive.scala
Last active August 15, 2019 02:34
A tail recursive function to calculate median of a List
import scala.util.Random
/**
* @author mandar2812
*/
object MedianRecursive {
def median(list: Stream[Double]): Double = {
val random: (Int) => Int = Random.nextInt
@mandar2812
mandar2812 / Hermite.scala
Created May 13, 2015 16:06
Tail Recursive function to calculate the Hermite polynomial of an arbitrary degree.
object Hermite {
def hermite(n: Int, x: Double): Double = {
def hermiteHelper(k: Int, x: Double, a: Double, b: Double): Double =
k match {
case 0 => a
case 1 => b
case _ => hermiteHelper(k-1, x, b, x*b - (k-1)*a)
}
hermiteHelper(n, x, 1, x)
}
@mandar2812
mandar2812 / Stats.scala
Created May 13, 2015 16:11
Tail recursive calculation of sample mean and variance of a list of Breeze vectors
import breeze.linalg.DenseVector
object Stats {
/**
* Get the mean and variance of a data set
* which is a [[List]] of [[DenseVector]].
*
* @param data The data set.
*
* @return A [[Tuple2]] containing the mean
@mandar2812
mandar2812 / TestGPHousing.scala
Last active June 5, 2017 14:25
Test Gaussian Process Regression Models on the Boston Housing Data Set
import breeze.linalg.DenseVector
import io.github.mandar2812.dynaml.DynaMLPipe._
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
import io.github.mandar2812.dynaml.kernels._
import io.github.mandar2812.dynaml.modelpipe.GPRegressionPipe
import io.github.mandar2812.dynaml.models.gp.AbstractGPRegressionModel
import io.github.mandar2812.dynaml.pipes.{BifurcationPipe, DataPipe, StreamDataPipe}
import io.github.mandar2812.dynaml.utils.GaussianScaler
/**
import breeze.linalg.{DenseMatrix, DenseVector}
import com.quantifind.charts.Highcharts._
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
import io.github.mandar2812.dynaml.kernels.{CovarianceFunction, LocalSVMKernel}
import io.github.mandar2812.dynaml.models.svm.DLSSVM
import io.github.mandar2812.dynaml.optimization.{GPMLOptimizer, GridSearch}
import io.github.mandar2812.dynaml.pipes.{StreamDataPipe, DynaMLPipe, DataPipe}
import org.apache.log4j.Logger
/**
import breeze.linalg.{DenseMatrix, DenseVector}
import com.quantifind.charts.Highcharts._
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
import io.github.mandar2812.dynaml.kernels.CovarianceFunction
import io.github.mandar2812.dynaml.models.gp.GPNarModel
import io.github.mandar2812.dynaml.optimization.{GPMLOptimizer, GridSearch}
import io.github.mandar2812.dynaml.pipes.{DynaMLPipe, DataPipe}
import org.apache.log4j.Logger
/**
import breeze.linalg.{DenseMatrix, DenseVector}
import com.quantifind.charts.Highcharts._
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
import io.github.mandar2812.dynaml.kernels.CovarianceFunction
import io.github.mandar2812.dynaml.models.gp.GPNarXModel
import io.github.mandar2812.dynaml.optimization.{GPMLOptimizer, GridSearch}
import io.github.mandar2812.dynaml.pipes.{StreamDataPipe, DynaMLPipe, DataPipe}
import org.apache.log4j.Logger
/**
import breeze.linalg.{DenseMatrix, DenseVector}
import io.github.mandar2812.dynaml.evaluation.RegressionMetrics
import io.github.mandar2812.dynaml.kernels._
import io.github.mandar2812.dynaml.models.gp.GPRegression
import io.github.mandar2812.dynaml.models.neuralnets.{FeedForwardNetwork, FFNeuralGraph}
import io.github.mandar2812.dynaml.pipes.{StreamDataPipe, DataPipe}
import io.github.mandar2812.dynaml.utils
/**
* Created by mandar on 11/1/16.
import breeze.linalg.DenseVector
import io.github.mandar2812.dynaml.evaluation.BinaryClassificationMetrics
import io.github.mandar2812.dynaml.models.neuralnets.{FFNeuralGraph, FeedForwardNetwork}
import io.github.mandar2812.dynaml.pipes.{DataPipe, DynaMLPipe, StreamDataPipe}
/**
* Created by mandar on 11/1/16.
*/
object TestNNWineQuality {
def apply (hidden: Int = 2, nCounts:List[Int] = List(), acts:List[String],
import breeze.linalg.DenseVector
import io.github.mandar2812.dynaml.evaluation.BinaryClassificationMetrics
import io.github.mandar2812.dynaml.models.lm.LogisticGLM
import io.github.mandar2812.dynaml.pipes.{DataPipe, DynaMLPipe, StreamDataPipe}
object TestLogisticWineQuality {
def apply(training: Int = 100, test: Int = 1000,
columns: List[Int] = List(11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
stepSize: Double = 0.01, maxIt: Int = 30, mini: Double = 1.0,
regularization: Double = 0.5, wineType: String = "red",