diff --git a/CHANGELOG.md b/CHANGELOG.md index b0195b1..73e63f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Index searching to data manager. * Search highlighting in data manager. +* "Unlabel" option to remove previously labeled data from training set. ### Fixed * Data column sorting not working. * Needing to render the notebook's first model view cell twice for ipyvuetify - stylesheets to propagate. + stylesheets to propagate. (Use `icat.initialize()` now, instead of + `pn.extension()`) diff --git a/icat/data.py b/icat/data.py index 355cbe6..ab34c4f 100644 --- a/icat/data.py +++ b/icat/data.py @@ -323,6 +323,7 @@ def _handle_ipv_search_cleared(self, widget, event, data): self.search_value = "" self.search_box.success = False self.search_box.error = False + self.search_box.label = "Search (use 'ID:X' to search index)" def _handle_row_selected(self, point_id): """Event handler from table row select.""" diff --git a/icat/model.py b/icat/model.py index cd532fc..55dde3d 100644 --- a/icat/model.py +++ b/icat/model.py @@ -73,7 +73,11 @@ def __init__( self.anchor_list.build_tfidf_features() def _on_data_label(self, index: int | list[int], new_label: int | list[int]): - """Event handler for datamanager.""" + """Event handler for datamanager. + + if a -1 is passed for (or in the list of) new_label, remove it from the + training data, if found. + """ # expand a single value pass to list for consistent handling below if type(index) != list: @@ -98,22 +102,12 @@ def _on_data_label(self, index: int | list[int], new_label: int | list[int]): ] ) - # update if it's a row that's already in the training data - # elif ( - # index in self.training_data.index - # and self.training_data.loc[index, self.data.text_col] - # == self.data.active_data.loc[index, self.data.text_col] - # ): - # self.training_data.at[index, self.data.label_col] = new_label - - # else: - # self.training_data = pd.concat( - # # self.training_data, pd.DataFrame(self.data.active_data[index, :]) - # [ - # self.training_data, - # pd.DataFrame([self.data.active_data.loc[index, :]]), - # ] - # ) + # Remove any rows from the resulting table where the label_col is "-1", indicating an + # unlabelling operation + self.training_data = self.training_data.drop( + self.training_data[self.training_data[self.data.label_col] == -1].index + ) + # note that we don't call fit because we don't need to re-featurize, only a label has changed self._train_model() self.view.refresh_data() diff --git a/icat/table.py b/icat/table.py index c45c01a..b69f011 100644 --- a/icat/table.py +++ b/icat/table.py @@ -94,6 +94,10 @@ def vue_applyAbsoluteLabelInteresting(self, point_id): for callback in self._apply_label_callbacks: callback(point_id, 1) + def vue_applyAbsoluteLabelUnlabeled(self, point_id): + for callback in self._apply_label_callbacks: + callback(point_id, -1) + def vue_addToExampleAnchor(self, point_id): for callback in self._add_example_callbacks: callback(point_id) @@ -152,6 +156,9 @@ def _template(self): Add this instance to the current sample set.
+