base
logger = logging.getLogger(__name__) module-attribute ¶
DataFetcher ¶
Bases: BaseModel
Represents a abstract class to be used by Dataset or Metadata subclass.
Source code in src/streamsight/datasets/base.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
config = DatasetConfig() class-attribute ¶
Configuration for the dataset.
file_path property ¶
File path of the dataset.
processed_cache_path property ¶
Path for cached processed data.
IS_BASE = True class-attribute instance-attribute ¶
name property ¶
Name of the object's class.
:return: Name of the object's class :rtype: str
fetch_dataset() ¶
Check if dataset is present, if not download
Source code in src/streamsight/datasets/base.py
39 40 41 42 43 44 45 | |
fetch_dataset_force() ¶
Force re-download of the dataset.
Source code in src/streamsight/datasets/base.py
47 48 49 50 | |
Dataset ¶
Bases: DataFetcher
Represents a collaborative filtering dataset.
Dataset must minimally contain user, item and timestamp columns for the other modules to work.
Assumption¶
User/item ID increments in the order of time. This is an assumption that will be made for the purposes of splitting the dataset and eventually passing the dataset to the model. The ID incrementing in the order of time allows us to set the shape of the currently known user and item matrix allowing easier manipulation of the data by the evaluator.
:param filename: Name of the file, if no name is provided the dataset default will be used if known. If the dataset does not have a default filename, a ValueError will be raised. :type filename: str, optional :param base_path: The base_path to the data directory. Defaults to data :type base_path: str, optional :param use_default_filters: If True, the default filters will be applied to the dataset. Defaults to False. :type use_default_filters: bool, optional
Source code in src/streamsight/datasets/base.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
config = DatasetConfig() class-attribute ¶
Configuration for the dataset.
fetch_metadata = fetch_metadata instance-attribute ¶
preprocessor = DataFramePreprocessor(self.config.item_ix, self.config.user_ix, self.config.timestamp_ix) instance-attribute ¶
IS_BASE = True class-attribute instance-attribute ¶
name property ¶
Name of the object's class.
:return: Name of the object's class :rtype: str
file_path property ¶
File path of the dataset.
processed_cache_path property ¶
Path for cached processed data.
add_filter(filter_) ¶
Add a filter to be applied when loading the data.
Utilize :class:DataFramePreprocessor class to add filters to the dataset to load. The filter will be applied when the data is loaded into an :class:InteractionMatrix object when :meth:load is called.
:param filter_: Filter to be applied to the loaded DataFrame processing to interaction matrix. :type filter_: Filter
Source code in src/streamsight/datasets/base.py
221 222 223 224 225 226 227 228 229 230 231 232 | |
load(apply_filters=True, use_cache=True) ¶
Loads data into an InteractionMatrix object.
Data is loaded into a DataFrame using the :func:_load_dataframe function. Resulting DataFrame is parsed into an :class:InteractionMatrix object. If :data:apply_filters is set to True, the filters set will be applied to the dataset and mapping of user and item ids will be done. This is advised even if there is no filter set, as it will ensure that the user and item ids are incrementing in the order of time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apply_filters | bool | To apply the filters set and preprocessing, defaults to True | True |
use_cache | bool | Whether to use cached processed data, defaults to True | True |
Returns:
| Type | Description |
|---|---|
InteractionMatrix | Resulting interaction matrix. |
Source code in src/streamsight/datasets/base.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
fetch_dataset() ¶
Check if dataset is present, if not download
Source code in src/streamsight/datasets/base.py
39 40 41 42 43 44 45 | |
fetch_dataset_force() ¶
Force re-download of the dataset.
Source code in src/streamsight/datasets/base.py
47 48 49 50 | |