average is slow:

```
>>> y = np.random.randn(10000)
>>> pred = np.random.randn(10000)
>>> sample_weight = np.random.randn(10000)
>>> %timeit np.average((y - pred) ** 2, weights=sample_weight)
1000 loops, best of 3: 306 us per loop
>>> %timeit np.sum(sample_weight * ((y - pred) ** 2))
10000 loops, best of 3: 174 us per loop
```

`np.einsum` is also an option.