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 pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn | |
from sklearn.cluster import KMeans | |
import numpy as np | |
from scipy.spatial.distance import cdist, pdist | |
def elbow(df, n): | |
kMeansVar = [KMeans(n_clusters=k).fit(df.values) for k in range(1, n)] | |
centroids = [X.cluster_centers_ for X in kMeansVar] |
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 pandas as pd | |
def fillWithMean(df): | |
return df.fillna(df.mean()).dropna(axis=1, how='all') |
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 varianceSelection(X, THRESHOLD = .95): | |
sel = VarianceThreshold(threshold=(THRESHOLD * (1 - THRESHOLD))) | |
sel.fit_transform(X) | |
return X[[c for (s, c) in zip(sel.get_support(), X.columns.values) if s]] |
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
object Mappable { | |
implicit class ToMapOps[A](val a: A) extends AnyVal { | |
import shapeless._ | |
import ops.record._ | |
def toMap[L <: HList](implicit | |
gen: LabelledGeneric.Aux[A, L], | |
tmr: ToMap[L] | |
): Map[String, Any] = { | |
val m: Map[tmr.Key, tmr.Value] = tmr(gen.to(a)) |
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
containers: | |
env: | |
image: davidshen84/scikit-learn | |
run: | |
publish: | |
- 8888:8888 | |
interactive: true | |
tty: true | |
volume: ["./data:/data", "./notebook:/notebook"] |
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 shapeless._ | |
sealed trait A | |
case object A1 extends A | |
case object A2 extends A | |
case object A3 extends A | |
case class B( | |
A1: String, | |
A2: String, | |
A3: String |
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
alias sbt='f() { sbt "$@" |tee -a ~/.sbtlogs; };f' |
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 midi #pip install python-midi (https://github.com/vishnubob/python-midi) | |
pattern = midi.Pattern() | |
track = midi.Track() | |
pattern.append(track) | |
on = midi.NoteOnEvent(tick=0, velocity=100, pitch=60) | |
track.append(on) | |
off = midi.NoteOffEvent(tick=100, pitch=60) | |
track.append(off) | |
eot = midi.EndOfTrackEvent(tick=1) |
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
echo “very spoofy” | mail -s “much boring” [email protected] |
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 intervals | |
import scala.language.implicitConversions | |
import cats.Monoid | |
import cats.syntax.foldable._ | |
import cats.instances.list._ | |
import scala.math.Ordering | |
object Main extends App { | |
import Interval._ |
OlderNewer