Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal to encode predictions as proba now works #447

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions frameworks/TPOT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ def run(dataset: Dataset, config: TaskConfig):
)

def process_results(results):
if results.probabilities is not None and not results.probabilities.shape: # numpy load always return an array
prob_format = results.probabilities.item()
if prob_format == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
else:
raise ValueError(f"Unknown probabilities format: {prob_format}")
return results
if isinstance(results.probabilities, str) and results.probabilities == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
is_numpy_like = hasattr(results.probabilities, "shape") and results.probabilities.shape
if results.probabilities is None or is_numpy_like:
return results
raise ValueError(f"Unknown probabilities format: {results.probabilities}")

return run_in_venv(__file__, "exec.py",
input_data=data, dataset=dataset, config=config,
Expand Down
15 changes: 7 additions & 8 deletions frameworks/hyperoptsklearn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ def run(dataset: Dataset, config: TaskConfig):
)

def process_results(results):
if results.probabilities is not None and not results.probabilities.shape: # numpy load always return an array
prob_format = results.probabilities.item()
if prob_format == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
else:
raise ValueError(f"Unknown probabilities format: {prob_format}")
return results
if isinstance(results.probabilities, str) and results.probabilities == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
is_numpy_like = hasattr(results.probabilities, "shape") and results.probabilities.shape
if results.probabilities is None or is_numpy_like:
return results
raise ValueError(f"Unknown probabilities format: {results.probabilities}")

return run_in_venv(__file__, "exec.py",
input_data=data, dataset=dataset, config=config,
Expand Down
15 changes: 7 additions & 8 deletions frameworks/oboe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ def run(dataset: Dataset, config: TaskConfig):
)

def process_results(results):
if results.probabilities is not None and not results.probabilities.shape: # numpy load always return an array
prob_format = results.probabilities.item()
if prob_format == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
else:
raise ValueError(f"Unknown probabilities format: {prob_format}")
return results
if isinstance(results.probabilities, str) and results.probabilities == "predictions":
target_values_enc = dataset.target.label_encoder.transform(dataset.target.values)
results.probabilities = Encoder('one-hot', target=False, encoded_type=float).fit(target_values_enc).transform(results.predictions)
is_numpy_like = hasattr(results.probabilities, "shape") and results.probabilities.shape
if results.probabilities is None or is_numpy_like:
return results
raise ValueError(f"Unknown probabilities format: {results.probabilities}")

return run_in_venv(__file__, "exec.py",
input_data=data, dataset=dataset, config=config,
Expand Down