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.

  • 2
    $\begingroup$ I would say there should be 0 or 2 commas, but either is acceptable. $\endgroup$
    – Mark Grant
    Oct 9, 2019 at 15:30
  • 3
    $\begingroup$ 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. $\endgroup$
    – Dan Ramras
    Oct 9, 2019 at 16:32
  • 3
    $\begingroup$ 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. $\endgroup$ Oct 9, 2019 at 17:44
  • $\begingroup$ 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. $\endgroup$
    – R.P.
    Oct 10, 2019 at 7:17


Browse other questions tagged or ask your own question.