{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Fitting an Elastic Net with a precomputed Gram Matrix and Weighted Samples\n\nThe following example shows how to precompute the gram matrix\nwhile using weighted samples with an :class:`~sklearn.linear_model.ElasticNet`.\n\nIf weighted samples are used, the design matrix must be centered and then\nrescaled by the square root of the weight vector before the gram matrix\nis computed.\n\n
`sample_weight` vector is also rescaled to sum to `n_samples`, see the\n documentation for the `sample_weight` parameter to\n :meth:`~sklearn.linear_model.ElasticNet.fit`.