Skip to content

Commit

Permalink
Changed strategic logistic loss to avoid adding a second gaming stage (
Browse files Browse the repository at this point in the history
…#22)

* Changed strategic logistic loss to avoid adding a second gaming stage

* Renamed strategic_logistic_loss
  • Loading branch information
yoshavit authored May 25, 2020
1 parent e33e56b commit f2729da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion whynot/simulators/credit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
dynamics,
Intervention,
simulate,
strategic_logistic_loss,
logistic_loss,
State,
)

Expand Down
4 changes: 2 additions & 2 deletions whynot/simulators/credit/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
Config,
Intervention,
simulate,
strategic_logistic_loss,
logistic_loss,
State,
)


def compute_reward(intervention, state, config):
"""Compute the reward based on the observed state and choosen intervention."""
return strategic_logistic_loss(
return logistic_loss(
config, state.features, state.labels, intervention.updates["theta"],
)

Expand Down
9 changes: 3 additions & 6 deletions whynot/simulators/credit/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,14 @@ def __init__(self, time=30, **kwargs):
super(Intervention, self).__init__(Config, time, **kwargs)


def strategic_logistic_loss(config, features, labels, theta):
def logistic_loss(config, features, labels, theta):
"""Evaluate the performative loss for logistic regression classifier."""

config = config.update(Intervention(theta=theta))

# Compute adjusted data
strategic_features = agent_model(features, config)

# compute log likelihood
num_samples = strategic_features.shape[0]
logits = strategic_features @ config.theta
num_samples = features.shape[0]
logits = features @ config.theta
log_likelihood = (1.0 / num_samples) * np.sum(
-1.0 * np.multiply(labels, logits) + np.log(1 + np.exp(logits))
)
Expand Down

0 comments on commit f2729da

Please sign in to comment.