<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fit(self):
 """ Do the fitting. Does least square fitting. If you want to use custom fitting, must override this. """

        # the objective function that will be minimized in the least square
        # fitting
        objective_func = lambda pars, x, y: y - self._func(x, pars)
        self._params = self._initial_guess()
        self.eos_params, ierr = leastsq(
            objective_func, self._params, args=(self.volumes, self.energies))
        # e0, b0, b1, v0
        self._params = self.eos_params
        if ierr not in [1, 2, 3, 4]:
            raise EOSError("Optimal parameters not found")