|
28 | 28 | from ads.feature_store.execution_strategy.execution_strategy_provider import (
|
29 | 29 | OciExecutionStrategyProvider,
|
30 | 30 | )
|
| 31 | +from ads.feature_store.feature import Feature |
31 | 32 | from ads.feature_store.feature import DatasetFeature
|
32 | 33 | from ads.feature_store.feature_group_expectation import Expectation
|
33 | 34 | from ads.feature_store.feature_option_details import FeatureOptionDetails
|
@@ -245,9 +246,20 @@ def id(self) -> str:
|
245 | 246 | """
|
246 | 247 | return self.get_spec(self.CONST_ID)
|
247 | 248 |
|
| 249 | + @property |
| 250 | + def features(self) -> List[Feature]: |
| 251 | + return [ |
| 252 | + Feature(**feature_dict) |
| 253 | + for feature_dict in self.get_spec(self.CONST_OUTPUT_FEATURE_DETAILS)[ |
| 254 | + self.CONST_ITEMS |
| 255 | + ] |
| 256 | + or [] |
| 257 | + ] |
| 258 | + |
248 | 259 | def with_id(self, id: str) -> "Dataset":
|
249 | 260 | return self.set_spec(self.CONST_ID, id)
|
250 | 261 |
|
| 262 | + |
251 | 263 | def with_job_id(self, dataset_job_id: str) -> "Dataset":
|
252 | 264 | """Sets the job_id for the last running job.
|
253 | 265 |
|
@@ -709,6 +721,33 @@ def delete(self):
|
709 | 721 |
|
710 | 722 | dataset_execution_strategy.delete_dataset(self, dataset_job)
|
711 | 723 |
|
| 724 | + def get_features(self) -> List[Feature]: |
| 725 | + """ |
| 726 | + Returns all the features in the dataset. |
| 727 | +
|
| 728 | + Returns: |
| 729 | + List[Feature] |
| 730 | + """ |
| 731 | + |
| 732 | + return self.features |
| 733 | + |
| 734 | + def get_features_df(self) -> "pandas.DataFrame": |
| 735 | + """ |
| 736 | + Returns all the features as pandas dataframe. |
| 737 | +
|
| 738 | + Returns: |
| 739 | + pandas.DataFrame |
| 740 | + """ |
| 741 | + records = [] |
| 742 | + for feature in self.features: |
| 743 | + records.append( |
| 744 | + { |
| 745 | + "name": feature.feature_name, |
| 746 | + "type": feature.feature_type, |
| 747 | + "feature_group_id": feature.feature_group_id, |
| 748 | + } |
| 749 | + ) |
| 750 | + return pandas.DataFrame.from_records(records) |
712 | 751 | def update(self, **kwargs) -> "Dataset":
|
713 | 752 | """Updates Dataset in the feature store.
|
714 | 753 |
|
|
0 commit comments