I have a dataframe of the format cp= [cars['car_models']=="chevy"] How is it possible to get the average of cp?
have looked everywhere for how to this this. thanks for the help
I have a dataframe of the format cp= [cars['car_models']=="chevy"] How is it possible to get the average of cp?
have looked everywhere for how to this this. thanks for the help
As @papayawarrior said, SFrames don't have averages. SArrays (of type float/int) might have these.
>>> sf = gl.SFrame({"x":[1,2,3]}) # SFrame with a single column (SArray) x.
>>> sf["x"].mean() # sf["x"] grabs the SArray x, then we take its average.
2.0
If you want the root mean square error, you should also have two SArrays (maybe in the same SFrame). I don't know what a "root mean squared value" is.
import graphlab as gl
cars = gl.SFrame({
"car_models": ["chevy", "ford", "chevy"],
"targets": [1, 2, 3],
"predictions": [7, 9, 8]
})
cp = cars[cars["car_models"] == "chevy"]
rmse = gl.evaluation.rmse(cp["targets"], cp["predictions"])
The rmse
in this example is 5.522680508593631 .