Weighted linear regression with Scikit-learn
<p>My data:</p>

<pre><code>State           N           Var1            Var2
Alabama         23          54              42
Alaska          4           53              53
Arizona         53          75              65
</code></pre>

<p><code>Var1</code> and <code>Var2</code> are aggregated percentage values at the state level. <code>N</code> is the number of participants in each state. I would like to run a linear regression between <code>Var1</code> and <code>Var2</code> with the consideration of <code>N</code> as weight with sklearn in Python 2.7.</p>

<p>The general line is:</p>

<pre><code>fit(X, y[, sample_weight])
</code></pre>

<p>Say the data is loaded into <code>df</code> using Pandas and the <code>N</code> becomes <code>df["N"]</code>, do I simply fit the data into the following line or do I need to process the N somehow before using it as <code>sample_weight</code> in the command?</p>

<pre><code>fit(df["Var1"], df["Var2"], sample_weight=df["N"])
</code></pre>