Fix incompatible types in assignment#344
Fix incompatible types in assignment#344daikikatsuragawa wants to merge 3 commits intointerpretml:mainfrom
Conversation
Signed-off-by: Daiki Katsuragawa <50144563+daikikatsuragawa@users.noreply.github.com>
| def compute_yloss(self, cfs, desired_range, desired_class): | ||
| """Computes the first part (y-loss) of the loss function.""" | ||
| yloss = 0.0 | ||
| yloss: Any = 0.0 |
There was a problem hiding this comment.
Currently, multiple types of values are stored.
| def compute_yloss(self): | ||
| """Computes the first part (y-loss) of the loss function.""" | ||
| yloss = 0.0 | ||
| yloss: Any = 0.0 |
There was a problem hiding this comment.
Currently, multiple types of values are stored.
| """Adds a linear equality constraints to the loss functions - | ||
| to ensure all levels of a categorical variable sums to one""" | ||
| regularization_loss = 0.0 | ||
| regularization_loss: Any = 0.0 |
There was a problem hiding this comment.
Currently, multiple types of values are stored.
| if desired_class == "opposite": | ||
| desired_class = 1.0 - np.round(test_pred) | ||
| self.target_cf_class = torch.tensor(desired_class).float() | ||
| self.target_cf_class: Any = torch.tensor(desired_class).float() |
There was a problem hiding this comment.
Currently, multiple types of values are stored.
| one_init.append(query_instance[0][i]) | ||
| one_init = np.array([one_init], dtype=np.float32) | ||
| self.cfs[n].assign(one_init) | ||
| self.cfs[n].assign(np.array([one_init], dtype=np.float32)) |
There was a problem hiding this comment.
Substitute directly. This prevents one_init from being of more than one type.
Signed-off-by: Daiki Katsuragawa <50144563+daikikatsuragawa@users.noreply.github.com>
| train_dataset = torch.tensor(self.vae_train_feat).float() | ||
| train_dataset = torch.utils.data.DataLoader(train_dataset, batch_size=self.batch_size, shuffle=True) | ||
| train_dataset = torch.utils.data.DataLoader( | ||
| torch.tensor(self.vae_train_feat).float(), # type: ignore |
There was a problem hiding this comment.
Set type: ignore because the error depends on the implementation of torch.utils.data.DataLoader.
| train_dataset = torch.tensor(self.vae_train_feat).float() | ||
| train_dataset = torch.utils.data.DataLoader(train_dataset, batch_size=self.batch_size, shuffle=True) | ||
| train_dataset = torch.utils.data.DataLoader( | ||
| torch.tensor(self.vae_train_feat).float(), # type: ignore |
There was a problem hiding this comment.
Set type: ignore because the error depends on the implementation of torch.utils.data.DataLoader.
Codecov ReportBase: 72.04% // Head: 72.12% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #344 +/- ##
==========================================
+ Coverage 72.04% 72.12% +0.07%
==========================================
Files 26 26
Lines 3595 3598 +3
==========================================
+ Hits 2590 2595 +5
+ Misses 1005 1003 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Signed-off-by: Daiki Katsuragawa <50144563+daikikatsuragawa@users.noreply.github.com>
|
@daikikatsuragawa thanks for this contribution. Can you share a few lines on the motivation for this PR (e.g., why change |
|
Comment on each. After completion, send a message with a Mention. |
|
Operational error for |
gaugup
left a comment
There was a problem hiding this comment.
Should we enable mypy in dice-ml linting build and fix all the mypy errors?
Yes. However, some mypy errors remain at present. It would be good to add them to Lint after they have been resolved. |
During the function, the process immediately following was checked and it was determined that the type of DiCE/dice_ml/explainer_interfaces/dice_KD.py Lines 173 to 176 in 490b7ab
Probably this case ( |
Signed-off-by: Daiki Katsuragawa 50144563+daikikatsuragawa@users.noreply.github.com
This pull request is one of the steps of #331 . Most of the "
Incompatible types in assignment" errors detected by mypy are fixed. Basically, the policy is to modify the process without major changes. Therefore, there are also temporary responses (e.g., defining type hintsAny). These are excluded from the modifications in this pull request and will be revised later.In conclusion, this pull request will have the following effects.
Incompatible types in assignment" processes