How to do power curve fitting in Python?
<p>There is a question about exponential curve fitting, but I didn't find any materials on how to create a power curve fitting, like this:</p>

<pre><code>y = a*x^b
</code></pre>

<p>There is a way to do this in Excel, but is it possible in Python?</p>

<p>If you do an easy transformation you can apply the usual least squares regression.</p>

<p>Instead of this equation: </p>

<pre><code>y = a*x^b
</code></pre>

<p>Take the natural log of both sides:</p>

<pre><code>ln(y) = ln(a*x^b) = ln(a) + ln(x^b) = ln(a) + b*ln(x)
</code></pre>

<p>This is a linear equation in <code>[ln(x), ln(y)]</code> with slope <code>b</code> and intercept <code>ln(a)</code>.</p>

<p>You can use out of the box least squares fitting on the transformed data.</p>

python scikit-learn regression