When do crickets chirp more?

Computer Science Level pending

Here is a dataset describing the rate at which cricket chirps per second are heard in a secluded area, with respect to the temperature in Fahrenheit scale.

Using a linear regression model, predict the chirp frequency at 98° F. Enter your answer in s 1 s^{-1}


The answer is 20.459.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

For the relevant theory, see linear regression

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#this part is better done with pandas
import csv
data = csv.reader(open('slr02.csv'))
for row in data:
     chirps.append(float(row[0]))
     temp.append([float(row[1])])

from sklearn import linear_model
regr = linear_model.LinearRegression()
regr.fit(temp, chirps)

print regr.predict([[98]])[0]

That gives 20.45950597882

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...