Helpers
DEFAULT_API_BASE = 'https://www.openml.org/api/v1/'
module-attribute
class_counts(y, num_classes)
Bin integer-coded labels into a length-num_classes count vector.
Source code in src/helpers.py
287 288 289 290 291 292 | |
class_ratios(y, num_classes)
Class frequency ratios. Mirrors InstancesHelper.classRatios.
Source code in src/helpers.py
295 296 297 298 299 300 301 | |
download_and_parse(url)
Source code in src/helpers.py
29 30 31 32 | |
download_to_temp_file(url, suffix='', chunk_size=8192)
Download a URL to a temporary file.
Returns
str Path to the downloaded file.
Source code in src/helpers.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
get_data_and_meta_information_from_did(did, dataset_type='arff', base_url=DEFAULT_API_BASE)
Source code in src/helpers.py
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 | |
get_dataset_description_xml(did, base_url=DEFAULT_API_BASE)
Fetch /data/{did} and return the oml:data_set_description node.
Source code in src/helpers.py
136 137 138 139 140 | |
get_row_index(name, columns)
Return the 0-based index of name in columns, or -1 if absent.
Mirrors InstancesHelper.getRowIndex(String, Instances).
Source code in src/helpers.py
196 197 198 199 200 201 202 | |
get_row_index_multi(names, columns)
Return the index of the first name in names present in columns.
Raises ValueError if none of the names are found. Mirrors
InstancesHelper.getRowIndex(String[], Instances).
Source code in src/helpers.py
205 206 207 208 209 210 211 212 213 214 215 216 217 | |
get_run_xml(run_id, base_url=DEFAULT_API_BASE)
Fetch /run/{run_id} and return the oml:run node.
Source code in src/helpers.py
111 112 113 114 115 | |
get_task_inputs_xml(task_id, base_url=DEFAULT_API_BASE)
Fetch /task/inputs/{task_id} and return the oml:task_inputs node.
Distinct from get_task_xml — Java's MergeDataset uses
openml.taskInputs(taskId) which hits this endpoint, returning the
structured oml:inputs form with source_data_list etc.
Source code in src/helpers.py
125 126 127 128 129 130 131 132 133 | |
get_task_xml(task_id, base_url=DEFAULT_API_BASE)
Fetch /task/{task_id} and return the oml:task node.
Source code in src/helpers.py
118 119 120 121 122 | |
load_arff_to_df(path)
Load any ARFF file into a DataFrame, preserving column order.
Nominal columns become pd.Categorical with the declared categories,
matching what :func:src.process_dataset.module.load_dataset does for
dataset ARFFs.
Source code in src/helpers.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
normalize_target_names(target)
Source code in src/helpers.py
61 62 63 64 65 66 67 68 | |
openml_file_url(file_id, filename, base_url=DEFAULT_API_BASE)
Build a /data/download/{file_id}/{filename} URL — Java's
OpenmlConnector.getOpenmlFileUrl. The download host lives outside
/api/v1/, so it is derived from base_url via _server_root.
Source code in src/helpers.py
152 153 154 155 156 | |
prediction_to_confidences(confidence_values, prediction_value, class_names)
Build a confidence vector from a prediction row.
Mirrors InstancesHelper.predictionToConfidences. Raises ValueError
on missing values. If every confidence is 0, falls back to placing all
mass on the predicted class.
prediction_value may be either a class label (string) or a 0-based
integer class index — both are accepted, matching how Weka's
Instance.value() returns either form depending on attribute type.
Source code in src/helpers.py
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 | |
run_output_file_ids(run_xml)
Map output_data file names to file ids — Java's
Run.getOutputFileAsMap().
Source code in src/helpers.py
143 144 145 146 147 148 149 | |
task_cost_matrix(task_xml)
The cost_matrix input, or None if absent.
Source code in src/helpers.py
185 186 187 188 | |
task_estimation_procedure(task_xml)
The estimation_procedure input, or None if absent.
Source code in src/helpers.py
179 180 181 182 | |
task_source_data(task_xml)
The source_data input — Java's TaskInformation.getSourceData.
Source code in src/helpers.py
168 169 170 171 172 173 174 175 176 | |
to_prob_dist(d)
Normalize a vector to a probability distribution.
Replicates InstancesHelper.toProbDist exactly:
* If any element is +/- inf, the first such element becomes 1.0 and the
rest become 0.
* If all (non-nan) elements sum to 0, the first element becomes 1.0.
* Otherwise, divide each non-nan element by the total. NaNs become 0.
Source code in src/helpers.py
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 | |