@lru_cache(maxsize=None)<EOL><INDENT>def kde(self, term, bandwidth=<NUM_LIT>, samples=<NUM_LIT:1000>, kernel='<STR_LIT>'):<DEDENT>
<EOL>terms = np.array(self.terms[term])[:, np.newaxis]<EOL>kde = KernelDensity(kernel=kernel, bandwidth=bandwidth).fit(terms)<EOL>x_axis = np.linspace(<NUM_LIT:0>, len(self.tokens), samples)[:, np.newaxis]<EOL>scores = kde.score_samples(x_axis)<EOL>return np.exp(scores) * (len(self.tokens) / samples)<EOL>
Estimate the kernel density of the instances of term in the text.

Args:
    term (str): A stemmed term.
    bandwidth (int): The kernel bandwidth.
    samples (int): The number of evenly-spaced sample points.
    kernel (str): The kernel function.

Returns:
    np.array: The density estimate.