Danial Khosravi's Blog

Entrepreneur in the making...

Functional Programming in C#

| Comments

I got introduced to Functional Programming over 3 years ago and little by little, I ended up accumulating new ideas and ways of thinking that made me feel more confident at problem solving stage of coding. Functional Programming enabled me to have multiple options for solving a problem at hand.

Functional programming gave me a set of tools and a common way of thinking for solving literally any problem, async or sync, which allowed me to simplify every problem into smaller chunks and build my program by composing those chunks.

And every new language I learnt, functional or not, I kept applying these techniques or ways of thinking. Every new concept, higher order function, functional data structure or effect that I learnt, say in Haskell or Scala or even C#/TypeScript, was immediately ready for problem solving in other languages I knew, just had to find the right syntax or library that had those functional data structures to be able to work.

At my current job, the .NET stack is used for backend application development, React/TypeScript is used for Frontend and Scala/Spark for Big Data. As engineers, we are a practical bunch and a good few people have showed interest in learning more about Functional Programming.

After certain failed attempts/lack of support for trying to bring FP to our application development stack through the use of F# or trying to teach FP concepts using Haskell, I decided to delve deeper into doing FP in C# and create practical examples that can be beneficial to everyone in their current application without needing to “rewrite” the whole thing in a language they are comfortable with.

Functional Programming in C#, is the result of the talks I gave at my company and have managed to receive some good feedback from my peers, I hope these examples can be useful to others too.

You can find all the code and slides on here on github https://github.com/DanialK/fp-in-csharp


Shipping Deep Learning Models in Web and Mobile Applications

| Comments

Web Application (running in your browser!)

IOS Application

Source Code

Range of Convolutional Neural Networks on Fashion-MNIST Dataset

| Comments

Fashion MNIST is a drop-in replacement for the very well known, machine learning hello world, MNIST dataset. It has same number of training and test examples and the images have the same 28x28 size and there are a total of 10 classes/labels, you can read more about the dataset here : Fashion-MNIST

In this post we will be trying out different models and compare their results:

List of models

  1. 2 Layer Neural Netwoek
  2. CNN with 1 Convolutional Layer
  3. CNN with 3 Convolutional Layers
  4. VGG Like Model
  5. VGG Like Model With Batchnorm

Estimating Pi Using Monte Carlo Simulations

| Comments

Pi (3.141593) is one of the few magical numbers in Mathematics that we often trust, accept and use in our calculations. However, you might be curious to know where it comes from. Pi can be obtained analytically which gives us a value equal to 3.141593 but here we’re going to find the value of pi numerically by running Monte Carlo simulations.

Calculating Stocks’ Beta Using R

| Comments

According to Investopedia, Beta is a measure of the volatility, or systematic risk, of a security or a portfolio in comparison to the market as a whole. In this post, we’re going to learn how to calculate beta coefficient of our desired stocks using historical price data that is publicly available.

Below we will be covering

  • R script to calculate beta for Goldman Sachs
  • Maths behind the beta coefficient

R: Fancy Plots Using Ggplot2 and Ggthemes

| Comments

In this post I want to introduce you to a great ggplot2 add-on, ggthemes. ggthemes which is freely available on github, let you turn your current plots to professional looking plots in a matter of a couple of lines of code.

ggthemes has various of different themes such as The Economist, Excel and various other professional themes that makes your current plots much fancier.

Here is a plot that I made for one of my assignments this year using this library.

Check out more examples on its offical Github Repo

Multiline Plots in R Using Ggplot2

| Comments

With the help of ggplot2, creating beautiful charts is an easy task in R. However it can get a little bit tricky when you’re trying to plot a set of data on a single chart, over a shared x axis.