The first Random Forest library was coded in Fortran

Random Forest is a widely used method in machine learning. The first Random Forest library is coded in Fortran. See:

https://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm

It appears that the first Lasso regression library and Quantile regression library were also coded in Fortran.

It’s a pity that Fortran missed the whole machine learning era.

4 Likes

As recently as 2015, people on the R developers mailing list were asserting that Free source form Fortran 9x is not portable. I don’t know what that meant. People wanting to use a more modern language than C or FORTRAN 77 to write R packages turned to C++, using the Rcpp package. The FortLearner project has re-implemented many machine learning algorithms in modern Fortran and claims speed-ups compared to Python’s sciKit-learn. There are other projects for deep learning. Maybe Fortran can make a comeback.

3 Likes

I have a lot of free-form Fortran codes that can be loaded into R. Never encountered an issue. Some existing R packages also have free-form Fortran codes. It’s true that the R community is pushing for C/C++.

This FortLearner project is very intriguing. Thanks for sharing. I would like to see many of its algorithms ported to std.

1 Like

Agree Fortlearner looks very impressive.

I also never had a problem with R and Fortran 90+. Maybe the R maintainers meant to say “you need to use F77-style interfaces in code that interfaces directly with R” ? For example, I suppose you can’t use assumed-shape arrays in the interface of a function that is called directly from R via .C or .Fortran.

Nowadays I tend to interface Fortran code with R via the .Call interface and a C wrapper, using iso_c_binding. That said the .dotCall64 approach looks good.

2 Likes

Fortran is an ideal programming language to extend R for number-crunching tasks.

dotCall64 is great, but like Fortran, it is incredibly underdocumented and undermarketed. I am currently using dotCall64 for all my Fortran codes.

3 Likes