Skip to content

Commit

Permalink
Merge pull request #67 from artefactory/coeff-name
Browse files Browse the repository at this point in the history
ENH: coeff name in .report + some cLogit interpretation
  • Loading branch information
VincentAuriau authored Apr 18, 2024
2 parents 2ce0c24 + 1695dfd commit 4616a49
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This repository contains a private version of the package.
- [choice-learn-private](#choice-learn-private)
- [Introduction - Discrete Choice Modelling](#introduction---discrete-choice-modelling)
- [What's in there ?](#whats-in-there)
- [Getting Started](#getting-started---fast-track)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
Expand Down
5 changes: 4 additions & 1 deletion choice_learn/models/conditional_logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,10 @@ def compute_report(self, dataset):
i = 0
for weight in self.trainable_weights:
for j in range(weight.shape[1]):
names.append(f"{weight.name}_{j}")
if weight.shape[1] > 1:
names.append(f"{weight.name[:-2]}_{j}")
else:
names.append(f"{weight.name[:-2]}")
estimations.append(weight.numpy()[0][j])
z_values.append(weight.numpy()[0][j] / weights_std[i].numpy())
p_z.append(2 * (1 - dist.cdf(tf.math.abs(z_values[-1])).numpy()))
Expand Down
11 changes: 7 additions & 4 deletions choice_learn/models/simple_mnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ def compute_report(self, dataset):
p_z = []
i = 0
for weight in self.trainable_weights:
for j in range(weight.shape[0]):
names.append(f"{weight.name}_{j}")
estimations.append(weight.numpy()[j])
z_values.append(weight.numpy()[j] / weights_std[i].numpy())
for j in range(weight.shape[1]):
if weight.shape[1] > 1:
names.append(f"{weight.name[:-2]}_{j}")
else:
names.append(f"{weight.name[:-2]}")
estimations.append(weight.numpy()[0][j])
z_values.append(weight.numpy()[0][j] / weights_std[i].numpy())
p_z.append(2 * (1 - dist.cdf(tf.math.abs(z_values[-1])).numpy()))
i += 1

Expand Down
106 changes: 64 additions & 42 deletions notebooks/introduction/3_model_clogit.ipynb

Large diffs are not rendered by default.

0 comments on commit 4616a49

Please sign in to comment.