What preposition to use when fitting data?
Do we fit data with, by, or as a linear function?
None of those: we fit data to a function. See the usage throughout Wolfram Alpha, for example.
I would say you fit a function or model to the data, rather than the other way around. Or you find a model that fits the data.
It's kind of weird for me to say "fit data to a function". I don't think there is a big difference either way, but I prefer "fit a function to the data" and I think this latter way is the form I've always heard or read.
I think of it like how a tailor "fits" a dress or suite to a person's body, where the measurements are the data and the clothing piece is the function.
Actually, you don't do anything to data, which is the point to note.
You could say 'the data obeys/ conforms to/ or even fits, a (linear) function.'
It's important to note the difference between the inherent nature of the data and actions performed on the data.