Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ax.xaxis.set_label_position('top')
cax = ax.matshow(confusion_matrix, cmap='viridis')
ax.xaxis.set_major_locator(ticker.MultipleLocator(1))
ax.yaxis.set_major_locator(ticker.MultipleLocator(1))
ax.set_xticklabels([''] + labels, rotation=45, ha='left')
ax.set_yticklabels([''] + labels)
ax.grid(False)
ax.tick_params(axis='both', which='both', length=0)
fig.colorbar(cax, ax=ax, extend='max')
ax.set_xlabel('Predicted {}'.format(output_feature_name))
ax.set_ylabel('Actual {}'.format(output_feature_name))
plt.tight_layout()
ludwig.contrib.contrib_command("visualize_figure", plt.gcf())
if filename:
plt.savefig(filename)
else:
plt.show()
# Build model
if is_on_master():
print_boxed('BUILDING MODEL', print_fun=logger.debug)
model = Model(
model_definition['input_features'],
model_definition['output_features'],
model_definition['combiner'],
model_definition['training'],
model_definition['preprocessing'],
use_horovod=use_horovod,
random_seed=random_seed,
debug=debug
)
contrib_command("train_model", model, model_definition, model_load_path)
# Train model
if is_on_master():
print_boxed('TRAINING')
return model, model.train(
training_set,
validation_set=validation_set,
test_set=test_set,
save_path=save_path,
resume=resume,
skip_save_model=skip_save_model,
skip_save_progress=skip_save_progress,
skip_save_log=skip_save_log,
gpus=gpus, gpu_fraction=gpu_fraction,
random_seed=random_seed,
**model_definition['training']
'--host',
help='host for server (default: 0.0.0.0)',
default='0.0.0.0'
)
args = parser.parse_args(sys_argv)
logging.getLogger('ludwig').setLevel(
logging_level_registry[args.logging_level]
)
run_server(args.model_path, args.host, args.port)
if __name__ == '__main__':
contrib_command("serve", *sys.argv)
cli(sys.argv[1:])
def experiment(self):
from ludwig import experiment
ludwig.contrib.contrib_command("experiment", *sys.argv)
experiment.cli(sys.argv[2:])
args = parser.parse_args(sys_argv)
logging.getLogger('ludwig').setLevel(
logging_level_registry[args.logging_level]
)
set_on_master(args.use_horovod)
if is_on_master():
print_ludwig('Train', LUDWIG_VERSION)
full_train(**vars(args))
if __name__ == '__main__':
contrib_command("train", *sys.argv)
cli(sys.argv[1:])
print_test_results(test_results)
if not skip_save_test_predictions:
save_prediction_outputs(
postprocessed_output,
experiment_dir_name
)
if not skip_save_test_statistics:
save_test_statistics(test_results, experiment_dir_name)
model.close_session()
if is_on_master():
logger.info('\nFinished: {0}_{1}'.format(
experiment_name, model_name))
logger.info('Saved to: {}'.format(experiment_dir_name))
contrib_command("experiment_save", experiment_dir_name)
return experiment_dir_name
colors = plt.get_cmap('tab10').colors
ax.set_xlabel('class')
ax.set_xticks(ticks + width)
if labels is not None:
ax.set_xticklabels(labels, rotation=90)
else:
ax.set_xticklabels(ticks, rotation=90)
for i, score in enumerate(scores):
ax.bar(ticks + i * width, score, width, label=metrics[i],
color=colors[i])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.tight_layout()
ludwig.contrib.contrib_command("visualize_figure", plt.gcf())
if filename:
plt.savefig(filename)
else:
plt.show()
ax.plot(points[:, 0], points[:, 1], linewidth=3, marker='o',
fillstyle='full',
markerfacecolor='white',
markeredgecolor=color,
markeredgewidth=2,
color=color, zorder=10, label=label)
draw_polygon(ground_truth, 'Ground Truth')
# Draw polygon representing values
for i, alg_predictions in enumerate(predictions):
draw_polygon(alg_predictions, algorithms[i], colors[i])
ax.legend(frameon=True, loc='upper left')
plt.tight_layout()
ludwig.contrib.contrib_command("visualize_figure", plt.gcf())
if filename:
plt.savefig(filename)
else:
plt.show()