Does swapping 3rds and 7ths preserve harmonic feel?

The ii-V-I chord changes are arguably the most basic stable of jazz harmony, and exploring what’s so compelling about this chord is always a good way to diving into what’s harmony in jazz is all about. Recently the youtuber Charles Cornell published a nice video in his channel exploring how ii-V-I changes in major have a very nice pattern of leading tones involving thirds and sevenths, and how this drives the harmony forward in such a compelling way, by stacking compelling resolutions that continuously release the tension built by moving the chords around.

March 13, 2022

Could Neural Nets be used for Symbolic Optimization? Maybe.

What’s Symbolic Optimization A while ago I was entertaining problems in the intersection of symbolic manipulation of expressions and Deep Learning. In particular I was interested in finding “optimal” expressions in some way. So, imagine you have some grammar $G$ that describe a set of expressions, let’s call it $\mathrm{Exp}_G$, and suppose we have a real-valued function that takes an expression and maps into a number $f: \mathrm{Exp}_G \to \mathbb{R}$. The problem I want to discuss is finding expressions that minimize that function:

July 2, 2021

Negative Harmony inverts brightness of modes

Intro Recently I’ve been listening to a 12tone video on YouTube about negative harmony, a concept recently popularized by musician Jacob Collier. On the related links I found a bunch of videos from this channel with “negative harmony” versions of many popular songs. The change in sonority of those songs clearly indicated for me a change in the mode of the song, which kind of go against the grain of what I’ve been told about the action of those transformations.

February 20, 2021

A few frustrations with Python's type annotation system

I have on and off again tried to use mypy to type check my python code, but some shortcomings of Python’s type annotation system really get in the way. This came now because I needed to write code involving trees that had to change the types of values stored on the nodes. This highlighted a few serious shortcomings for anyone that is accostumed to use stronger type systems. The ugly syntax for function types is annoying but there are worse problems Yes, writing Callable[[Callable[[A], B], F[A]], F[B]] instead of (a -> b) -> f a -> f b as in Haskell or (A => B, F[A]) => F[B] (or maybe the uncurried (A => B) => (F[A] => F[B]) version) as in Scala is really annoying.

January 20, 2019

Type safe records as an excuse to learn type level programming in Haskell

I’ve been recently trying to learn more advanced type-level constructs in Haskell and was very happy to find this amazing talk by Prof. Stephanie Weirich about Dependent Types in haskell. This talk helped me to understand deeper a few more recent concepts introduced by some of GHC’s extensions and how to use them. In this post I want to focus a little bit in a simplified version of one of the data structures Prof.

February 12, 2018

Operational Semantics for Monads

Disclaimer: this is an old blog post from a very old wordpress blog and may contain inacuracies. I reproduced it as is for sentimental reasons. I may revisit this theme later. While randomly browsing around on Planet Haskell I’ve found a post on Heinrich Apfelmus' blog about something called “operational semantics” for monads. Found it very iluminating. Basically it’s a form to implement monads focusing not on defining the bind and return operators, but on what the monad is really supposed to do.

August 25, 2010

Stochastic Processes as Monad Transformers

Disclaimer: this is an old blog post from a very old wordpress blog and may contain inacuracies. I reproduced it as is for sentimental reasons. I may revisit this theme later. I have a difficulty to understand functional programming concepts that I can’t put to some very simple and natural use (natural for me, of course). I need to find the perfect simple example to implement to finally understand something. And I’m not a computer scientist, so things like parsers and compilers have very little appeal to me (probably because I don’t understand them…).

August 3, 2010

Rafael S. Calsaverini

Scan contact card

Scannable QR code with contact info

This is my personal page. Here you will find information about me and, from time to time, some blog posts about topics that interest me – tipically about Machine Learning, Statistical Physics, Bayesian Inference, and functional programming or sofware related stuff in general – and a few comments on other topics. Most of the posts are in English, but some things in Portuguese might pop out every now and then.


Data Science Manager


Dec 2019 - Present

Senior R&D Engineer


Oct 2018 - Nov 2019

Data Science Manager


Managed teams of data scientists and software engineers developing Machine Learning software. Responsible for people management, communicating with upper management and clients, reporting results, influencing good technical practices and technical excelence, discussing new projects with business and product teams, generating and evaluating new opportunities.

Sep 2017 - Sep 2018

Senior Data Scientist

Serasa Experian

Engaged with new technologies and research in Machine Learning to evaluate applicability in innovative projects. Applied bleeding-edge research algorithms into transactional datasets, credit modelling, marketing. Provided tech leadership to a distinguished team of top tier data scientists.

Nov 2015 - Aug 2017

Senior Data Scientist


Head of both data science and business inteligence initiatives. Lead a team of interns on BI tasks serving other teams, while developing algorithms for transaction classification and credit scoring from transactional data.

Apr 2015 - Oct 2015

Senior Data Scientist

Catho Online

Tech Lead of recommender system team. Developed and improved a contextual recommender engine on two research fronts and built a bayesian contextual bandit algorithm to select recommendation strategies.

Jul 2013 - Apr 2015

Data Scientist

Apontador & Maplink

Developed methods for improving geolocated search, a proof-of-concept recommender engine and several techniques for record linkage.

Apr 2012 - Jul 2013

PhD Candidate

Universidade de São Paulo

Did my Ph.D. Research in Statistical Mechanics of Complex Systems

Feb 2008 - Apr 2013


Universidade de São Paulo, Instituto de Física

PhD - Physics

Thesis: Topics in statistical physics of complex systems.

2008 - 2013

Universidade de São Paulo, Instituto de Física de São Carlos

MSc - Physics

Thesis: Inter-subband spin-orbit coupling in semiconductor heterostructures.

2005 - 2007

Universidade de São Paulo, Instituto de Física de São Carlos

BS - Physics

2000 - 2004


Data Science
  • Data Wrangling
  • Bayesian and Probabilistic Models
  • Machine Learning
  • Deep Learning
  • Deep Generative Models
Languages, Operating Systems & Tools
  • Python
  • Haskell
  • Scala
  • SQL
  • git
  • linux
  • Apache Spark
Libraries & Frameworks
  • Scikit Learn
  • Pandas
  • Tensorflow
  • Keras
  • Pytorch
  • numpy
  • scipy