Comma usage when defining symbols [closed]

Consider the following sentence that introduces a symbol, $$f$$, used later in the text (not shown):

A classifier is a function $$f$$, which takes an image as input and produces a label as output.

Should there be a comma before $$f$$? That is, should it say:

A classifier is a function, $$f$$, which takes an image as input and produces a label as output.

closed as off-topic by YCor, user44191, Carlo Beenakker, Gerald Edgar, R. van Dobben de BruynOct 9 at 17:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about research level mathematics within the scope defined in the help center." – user44191, Carlo Beenakker, Gerald Edgar, R. van Dobben de Bruyn
If this question can be reworded to fit the rules in the help center, please edit the question.

• I would say there should be 0 or 2 commas, but either is acceptable. – Mark Grant Oct 9 at 15:30
• It's worth noting that usually "which" follows a comma but and without the comma "that" is more standard. Note that the name $f$ is hardly important here in terms of the meaning of the sentence, and without it "A classifier is a function that..." has a different sense than "A classifier is a function, which...". The latter makes it sounds as though you're saying that a classifier and a function are the same thing, and then you're discussing their (common) nature. The former sounds like you're selecting out a certain type of function, and calling it a classifier. – Dan Ramras Oct 9 at 16:32
• The clause is restrictive, so it should be 'that' and not 'which'. There should be no comma. This is a convention of English writing, not mathematics. – R. van Dobben de Bruyn Oct 9 at 17:44
• Although the restrictive use of 'which' is extremely common and not really 'wrong'.I'd actually prefer it in a definition since it seems more formal to me. But I'd drop the commas. – RP_ Oct 10 at 7:17