I have the following formula

Citation: https://www.chess-journal.com/evaluatingSharpness1.html
In terms of my data frame:
w = "win"
d = "draw"
l = "loss"
and e is our buddy Euler's number.
What would be a tidy way of representing that final component? And should I use math.e for the e?
This is what I have so far
df = df.with_columns(
((pl.min_horizontal(pl.col("win"), pl.col("loss")) / 50) * (333 / pl.col("draw"))).alias("sharpness")
)
As in your case you need to exponent of the constant e, you can use pure polars expression - Expr.exp():
def sharpness(w, l, d):
a = pl.min_horizontal(w, l) / 50
b = 333 / d
c = -(w + l) / 1000
return a * b / (1 + c.exp())
df.with_columns(
sharpness(pl.col("win"), pl.col("loss"), pl.col("draw")).alias("sharpness")
)
Just a note, there's a way to apply exponent to the column - Expr.pow()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With