Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
output_features = [category_feature(vocab_size=2, reduce_input='sum')]
# Generate test data
rel_path = generate_data(input_features, output_features, csv_filename)
input_features[0]['encoder'] = 'parallel_cnn'
exp_dir_name = run_experiment(
input_features,
output_features,
data_csv=rel_path
)
output_feature_name = get_output_feature_name(exp_dir_name)
experiment_source_data_name = csv_filename.split('.')[0]
ground_truth = experiment_source_data_name + '.hdf5'
ground_truth_train_split = load_from_file(ground_truth, output_feature_name,
ground_truth_split=0)
ground_truth_val_split = load_from_file(ground_truth, output_feature_name,
ground_truth_split=1)
ground_truth_test_split = load_from_file(ground_truth, output_feature_name)
test_df, train_df, val_df = obtain_df_splits(csv_filename)
target_predictions_from_train = train_df[output_feature_name]
target_predictions_from_val = val_df[output_feature_name]
target_predictions_from_test = test_df[output_feature_name]
gtm_name = experiment_source_data_name + '.json'
ground_truth_metadata = load_json(gtm_name)
ground_truth_loaded_train_split = np.asarray([
ground_truth_metadata[output_feature_name]['str2idx'][train_row]
for train_row in target_predictions_from_train
])
ground_truth_loaded_val_split = np.asarray([
ground_truth,
ground_truth_split,
threshold_output_feature_names,
**kwargs
):
"""Load model data from files to be shown by
confidence_thresholding_2thresholds_2d_cli
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param threshold_output_feature_names: Name of the output feature to visualizes
:param kwargs: model configuration arguments
:return None:
"""
gt1 = load_from_file(
ground_truth,
threshold_output_feature_names[0],
ground_truth_split
)
gt2 = load_from_file(
ground_truth,
threshold_output_feature_names[1],
ground_truth_split
)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
confidence_thresholding_2thresholds_2d(
probabilities_per_model, [gt1, gt2], threshold_output_feature_names,
**kwargs
)
ground_truth_metadata,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by compare_classifiers_from_pred
:param predictions: Path to experiment predictions file
:param ground_truth: Path to ground truth file
:param ground_truth_metadata: Path to ground truth metadata file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
metadata = load_json(ground_truth_metadata)
predictions_per_model_raw = load_data_for_viz(
'load_from_file', predictions, dtype=str
)
predictions_per_model = [
np.ndarray.flatten(pred) for pred in predictions_per_model_raw
]
compare_classifiers_performance_from_pred(
predictions_per_model, gt, metadata, output_feature_name, **kwargs
)
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by
confidence_thresholding_data_vs_acc_cli.
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
confidence_thresholding_data_vs_acc(
probabilities_per_model, gt, **kwargs
)
probabilities,
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by compare_classifiers_from_prob.
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
compare_classifiers_performance_from_prob(
probabilities_per_model, gt, **kwargs
)
probabilities,
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by confidence_thresholding.
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
confidence_thresholding(
probabilities_per_model, gt, **kwargs
)
probabilities,
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by binary_threshold_vs_metric_cli.
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
binary_threshold_vs_metric(
probabilities_per_model, gt, **kwargs
)
predictions,
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by compare_classifiers_predictions
:param predictions: Path to experiment predictions file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
predictions_per_model = load_data_for_viz(
'load_from_file', predictions, dtype=str
)
compare_classifiers_predictions(predictions_per_model, gt, **kwargs)
ground_truth,
ground_truth_split,
threshold_output_feature_names,
**kwargs
):
"""Load model data from files to be shown by
confidence_thresholding_2thresholds_3d_cli
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param threshold_output_feature_names: Names of the output features to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt1 = load_from_file(
ground_truth,
threshold_output_feature_names[0],
ground_truth_split
)
gt2 = load_from_file(
ground_truth,
threshold_output_feature_names[1],
ground_truth_split
)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
confidence_thresholding_2thresholds_3d(
probabilities_per_model, [gt1, gt2], threshold_output_feature_names,
**kwargs
)
probabilities,
ground_truth,
ground_truth_split,
output_feature_name,
**kwargs
):
"""Load model data from files to be shown by compare_classifiers_subset.
:param probabilities: Path to experiment probabilities file
:param ground_truth: Path to ground truth file
:param ground_truth_split: Type of ground truth split - train, val, test
:param output_feature_name: Name of the output feature to visualize
:param kwargs: model configuration arguments
:return None:
"""
gt = load_from_file(ground_truth, output_feature_name, ground_truth_split)
probabilities_per_model = load_data_for_viz(
'load_from_file', probabilities, dtype=float
)
compare_classifiers_performance_subset(
probabilities_per_model, gt, **kwargs
)