Skip to content

Instantly share code, notes, and snippets.

Avatar

Joannes Vermorel vermorel

View GitHub Profile
@vermorel
vermorel / MurmurHash3.cs
Created Nov 26, 2018
Fast MurmurHash3 in C#
View MurmurHash3.cs
using System;
using System.Collections.Generic;
using Xunit;
namespace MyMurmurHash
{
/// <summary>
/// Fast hash - non-crypto secure. Intended to detect data storage
/// corruption.
/// </summary>
@vermorel
vermorel / fast_convolve_1D.cpp
Last active May 23, 2020
Fast 1D convolution with AVX
View fast_convolve_1D.cpp
// Fast 1D convolution with AXV
// By Joannes Vermorel, Lokad, January 2018
// Released under MIT license
#include <string.h>
#include <stdio.h>
#include <malloc.h>
/* A simple implementation of a 1D convolution that just iterates over
* scalar values of the input array.
@vermorel
vermorel / RandomForestC.cs
Created Jul 31, 2017
Classification. A monolithic random forest C# implementation. Ordinal and categorical variables
View RandomForestC.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
namespace Lokad
{
/// <summary>
@vermorel
vermorel / RandomForestR.cs
Last active Jul 31, 2017
Regression. A monolithic random forest C# implementation, categorical variables treated as ordinals
View RandomForestR.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
namespace Lokad
{
/// <summary>
/// A random forest tailored for regression, treading categorical variables as on ordinals.
@vermorel
vermorel / brainscript-helpers.cntk
Last active Aug 3, 2017
Handy bits of BrainScript code
View brainscript-helpers.cntk
# A constant 1D tensor that contains an enumeration 0 .. (count - 1).
Range(count) = Splice( array [0..(count-1)] ( i => Constant{i} ) )
# residual units
ResNet(InnerDim, OuterDim, INNODE) = {
L1 = DenseLayer {InnerDim, activation = ReLU, init = "gaussian"}( INNODE )
L2 = DenseLayer {OuterDim, activation = Pass, init = "gaussian"}( L1 )
ResUnit = ReLU(Plus(INNODE, L2))
}.ResUnit
@vermorel
vermorel / ZTransform.cs
Created Jul 6, 2017
C# Z-Transform, the discrete version of the Laplace transform
View ZTransform.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Lokad
{
/// <summary>
/// Z-Transform is the discrete version of the Laplace transform.
/// In their transformed form, the convolution of two distributions
/// is just the point-wise product of their Z-transform coefficients.
@vermorel
vermorel / Half.cs
Last active Nov 13, 2020
C# Half-precision data type
View Half.cs
/// ================ Half.cs ====================
/// The code is free to use for any reason without any restrictions.
/// Ladislav Lang (2009), Joannes Vermorel (2017)
using System;
using System.Diagnostics;
using System.Globalization;
namespace SystemHalf
{
@vermorel
vermorel / NaiveBayes.cs
Last active Apr 28, 2017
Classification with naive Bayes
View NaiveBayes.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Lokad
{
/// <summary>
/// Naive Bayesian classifier.
/// </summary>
/// <remarks>
@vermorel
vermorel / convert-daily.ps1
Last active Apr 4, 2016
Random expansion of monthly data into daily data
View convert-daily.ps1
# Random expansion of monthly data into daily data
# Syntax: convert-daily "c:\LokadData\foo.tsv"
# Expected columns are Id, Date, Quantity
# By Joannes Vermorel, April 2016
function convert-daily
{
param
(
[string] $file
@vermorel
vermorel / split-csv.ps1
Last active Jun 14, 2016
Split large CSV files into smaller files while preserving the headers
View split-csv.ps1
# Splitting large CSV files into smaller ones, preserving the headers
# By Joannes Vermorel, 2015-12-18
function Split-Csv
{
param
(
[string] $file,
[int] $maxLines
)
You can’t perform that action at this time.