Christmas is approaching again, and now is the time to prepare our spirit for it with the goodness of F#. Please join, reserve one of 56 slots, and spread your thoughts and love to F# with the community.
Join F# Advent Calendar today!
Rules
Choose F# a related topic for your blog post and reserve the slot on Twitter, Mastodon or leave a comment on this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English.
Publish your post on a specified date (according to the calendar).
Post the link to your post on Twitter or Mastodon with hashtags #fsharp and #FsAdvent.
Christmas is approaching again, and now is the time to prepare our spirit for it with the goodness of F#. Please join, reserve one of 62 slots and spread your thoughts and love to F# with the community.
This time you also have a possibility to support me (the host) with some coffee. This is optional but very appreciated if you like an event 😁.
Join F# Advent Calendar today!
Rules
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English.
Publish your post on a specified date (according to the calendar).
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
If you have sophisticated user feedback like rating (or likes and most importantly dislikes) then we can use Matrix Factorization algorithm to estimate unknown ratings.
If we have not only rating but other product fields, we can use more advanced algorithm called “Field-Aware Factorization Machine”
If we have no rating at all then “One Class Matrix Factorization” is the only option for us.
In this post I would like to focus on the last option.
One-Class Matrix Factorization
This algorithm can be used when data is limited. For example:
Books store: We have history of purchases (list of pairs userId + bookId) without user’s feedback and want to recommend new books for existing users.
Amazon store: We have history of co-purchases (list of pairs productId + productId) and want to recommend products in section “Customers Who Bought This Item Also Bought”.
Social network: We have information about user friendship (list of pairs userId + userId) and want to recommend users in section “People You May Know”.
As you already understood, it is applicable for a pair of 2 categorical variables, not only for userId + productId pairs.
Google showed several relevant posts about the usage of ML.NET One Class Matrix Factorizarion:
After reading all these 3 samples I realised that I do not fully understand what is Label column is used for. Later I came to a conclusion that all three samples most likely are incorrect and here is why.
There are three input columns required, one for matrix row indexes, one for matrix column indexes, and one for values (i.e., labels) in matrix. They together define a matrix in COO format. The type for label column is a vector of Single (float) while the other two columns are key type scalar.
COO stores a list of (row, column, value) tuples. Ideally, the entries are sorted first by row index and then by column index, to improve random access times. This is another format that is good for incremental matrix construction
So anyway we need three columns. If in the classic Matrix Factorization the Label column is the rating, then for One-Class Matrix Factorization we need to fill it with something else.
The second gem is
The coordinate descent method included is specifically for one-class matrix factorization where all observed ratings are positive signals (that is, all rating values are 1). Notice that the only way to invoke one-class matrix factorization is to assign one-class squared loss to loss function when calling MatrixFactorization(Options). See Page 6 and Page 28 here for a brief introduction to standard matrix factorization and one-class matrix factorization. The default setting induces standard matrix factorization. The underlying library used in ML.NET matrix factorization can be found on a Github repository.
As you see, Label is expected to be always 1, because we watched only One Class (positive rating): user downloaded a book, user purchased 2 items together, there is a friendship between two users.
In the case when data set does not provide rating to us, it is our responsibility to provide 1s to MatrixFactorizationTrainer and specify MatrixFactorizationTrainer.LossFunctionType as loss function.
This year was hard for all of us, we definitely deserve Christmas spirit and F# goodness. Please join, reserve one of 60 slots and spread your thoughts and love to F# with the community.
Join F# Advent Calendar today!
Rules
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English.
Publish your post on a specified date (according to the calendar).
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
Update 2019/11/14: As well as year before we will do extra slots again. We will start from slot for [Dec 18 – Dec 24] week, and when they are filled I will add slots for [Dec 11 – Dec 17], then for [Dec 1 – Dec 10] and finally [Dec 25-Dec 31].
F# Advent Calendar is a long tradition in F# community
Advent 2019 is coming, this year we have 56 free slots. Please join, reserve a slot and spread your thoughts and love to F# with the community.
This year I completely forgot to celebrate 7th birthday of F# Weekly. The very first F# Weekly #43, 2012 was published at 29/10/2012. Since than every 43th edition was an anniversary edition. Help me please celebrate the date – book your slot in #FsAdvent and deliver post in time!
Join F# Advent Calendar today!
Rules
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English.
Publish your post on a specified date (according to the calendar).
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
Update 2018/10/29:The vote showed that there is a demand for extra F# Advent slots, so I am going to follow suggestion from Reed Copsey and add new slots in portions. We will start from slot for [Dec 18 – Dec 24] week, and when they are filled I will add slots for [Dec 11 – Dec 17], then for [Dec 2 – Dec 10] and finally [Dec 25-Dec 31].
F# Advent Calendar is a long tradition in F# community
Advent 2018 is coming, this year we have 54 free slots. Please join, reserve a slot and spread your thoughts and love to F# with the community. A lot of amazing initiatives developed this year: F# 4.5, Fable2, Giraffe & Zebra, Fabulous, Saturn, TP SDK for .NET Core, FAKE 5, Early History of F#, Don Syme finally became F# Hero and much more!
Join F# Advent Calendar today!
Rules
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date (but you can).
Prepare a blog post in English
Publish your post on a specified date (according to the calendar)
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
Each year we’ve had an incredible Advent full of F# and Christmas spirit.
Advent 2017 is coming, this year we have 52 free slots. Do not to lose your chance to reserve a slot and spread your thoughts and love to F# with the community. A lot of amazing initiatives developed this year: Fable, Rider, Ionide, SAFE, Visual F#& VS15, dotNET Core, VS for Mac, Expecto, Azure Functions, new F# books and much more! Join F# Advent Calendar today!
Rules
Rules are very simple:
Choose F# related topic for your blog post and reserve the slot on Twitter or leave a comment to this post. Please note that you do not have to announce the topic until the date.
Prepare a blog post in English
Publish your post on a specified date (according to the calendar)
Post the link to your post on Twitter with hashtags #fsharp and #FsAdvent.
F# is a functional-first programming language that comes with a substantial object-oriented feature set. It is so feature-complete in fact, that almost any C# class can be ported over to F# code with little substantial alteration.
However significant, this subset of the language is seeing limited appreciation from the community, which I suspect is partly fuelled by the known criticisms of OOP and partly by a desire to be different than C#. After all, this is a functional-first language so we can just replace all our classes with functions. There is also the opinion that OOP in F# merely serves as a compatibility layer for .NET, so it’s really only there to cover those unfortunate scenarios of having to use a library that accepts interfaces.
Enabling Abstraction
One of the most important aspects of maintaining a nontrivial codebase is controlling complexity. Complexity can be contained by partitioning code into logically…
Exception handling is an error management paradigm that has often been met with criticism. Such criticisms typically revolve around scoping considerations, exceptions-as-control-flow abuse or even the assertion that exceptions are really just a type safe version of goto. To an extent, these seem like valid concerns but it is not within the scope of this article to address those per se.
Such concerns resonate particularly well within FP communities, often taken to the extreme: we should reject exceptions altogether, since code that throws is necessarily impure. In the F# community, this opinion is in part realized by advocating alternatives like result types and railway-oriented programming. In essence, these approaches follow the Either monad found in Haskell, but often intentionally avoiding the use of do notation/computation expressions (since that’s just interpreted exception semantics).
The TL;DR version of the approach is that we define a union type for results that looks…