Esempio n. 1
0
# select_label_method(sub_samples, 'y_radii')
# # train_samples, validation_samples = automatic_test.get_cross_validation_samples(sub_samples, 4)
# train_samples, validation_samples = automatic_test.get_partitioned_samples(sub_samples, 0.75)
# # Test 01 and 02
# automatic_test.train([whole_algo], train_samples)
# results = automatic_test.predict_all_estimators([whole_algo], validation_samples)
# for sample, prediction, predictions_all_estimators in zip(validation_samples, results[whole_algo]['predictions'], results[whole_algo]['predictions_all_estimators']):
#     automatic_test.output_sample_features(sample)
#     predicted_distances = [pred[0] for pred in predictions_all_estimators]
#     heatmap = get_heatmap_from_polar_all_predictors(predicted_distances, sample['geometry']['curve_secant'], sample['X'][_feature_types.index('intersection_angle')])
#     plot_intersection(sample, [prediction], rgbcolors=[cmap(0.6)], labels=[whole_algo.get_name()], heatmap=heatmap, orientation="curve-secant")


select_label_method(sub_samples, 'y_distances')
select_label_method(test_samples, 'y_distances')
# train_samples, validation_samples = automatic_test.get_cross_validation_samples(sub_samples, 4)
train_samples, validation_samples = automatic_test.get_partitioned_samples(sub_samples, 0.75)
# Test 03 and 04
automatic_test.train([whole_algo], train_samples)
# results = automatic_test.predict_all_estimators([whole_algo], test_samples)
results = automatic_test.predict_all_estimators([whole_algo], validation_samples)
for sample, prediction, predictions_all_estimators in zip(validation_samples, results[whole_algo]['predictions'], results[whole_algo]['predictions_all_estimators']):
# for sample, prediction, predictions_all_estimators in zip(test_samples, results[whole_algo]['predictions'], results[whole_algo]['predictions_all_estimators']):
    predicted_distances = [pred[0] for pred in predictions_all_estimators]
    half_angle_vec = get_half_angle_vec(sample['geometry']['exit_line'], sample['X'][_feature_types.index('intersection_angle')])
    heatmap = get_heatmap_from_distances_all_predictors(predicted_distances,
                                                    sample['geometry']['entry_line'],
                                                    sample['geometry']['exit_line'],
                                                    half_angle_vec)
    plot_intersection(sample, [prediction], rgbcolors=[cmap(0.6)], labels=[whole_algo.get_name()], heatmap=heatmap, orientation="curve-secant")
Esempio n. 2
0
sys.path.append('../')
import automatic_test
import regressors
import reference_implementations

feature_list = [
    "intersection_angle",                       # Angle between entry and exit way
    "maxspeed_entry",                           # Allowed maximum speed on entry way
    "maxspeed_exit",                            # Allowed maximum speed on exit way
    # "lane_distance_entry_exact",                # Distance of track line to curve secant center point at 0 degree angle
    # "lane_distance_exit_exact",                 # Distance of track line to curve secant center point at 180 degree angle
    "lane_distance_entry_lane_center",          # Distance of lane center line to curve secant ceter point at 0 degree angle
    "lane_distance_exit_lane_center",           # Distance of lane center line to curve secant ceter point at 180 degree angle
    "oneway_entry",                             # Is entry way a oneway street?
    "oneway_exit",                              # Is exit way a oneway street?
    "vehicle_speed_entry",                      # Measured vehicle speed on entry way at INT_DIST
    "vehicle_speed_exit"                        # Measured vehicle speed on exit way at INT_DIST
]
rf_algo = regressors.RandomForestAlgorithm(feature_list)
rfc_algo = regressors.RFClassificationAlgorithm(feature_list, bin_num=20, min_radius=6.0, max_radius=28.0, n_estimators=80)
#ispline_algo = reference_implementations.InterpolatingSplineAlgorithm()
algos = [rf_algo, rfc_algo]
samples = automatic_test.load_samples('../data/training_data/samples.pickle')
samples = automatic_test.normalize_features(samples)
train_samples, test_samples = automatic_test.get_partitioned_samples(samples, 0.8)
automatic_test.train(algos, train_samples)
results = automatic_test.predict(algos, test_samples)
results_proba = automatic_test.predict_proba([rfc_algo], test_samples)
automatic_test.show_intersection_plot(results, test_samples, results_proba, which_samples="best-worst-case", orientation="curve-secant")
# automatic_test.show_graph_plot(results, test_samples, results_proba, which_samples="best-worst-case")
Esempio n. 3
0
darmstadt_samples = automatic_test.load_samples('../data/training_data/samples_darmstadt/samples.pickle')
extract_features.select_label_method(kitti_samples, 'y_radii')
extract_features.select_label_method(darmstadt_samples, 'y_radii')
random.shuffle(kitti_samples)
random.shuffle(darmstadt_samples)
kitti_train_samples, kitti_test_samples = automatic_test.get_partitioned_samples(kitti_samples, 0.7)
darmstadt_train_samples, darmstadt_test_samples = automatic_test.get_partitioned_samples(darmstadt_samples, 0.7)
train_samples = kitti_train_samples + darmstadt_train_samples
test_samples = kitti_test_samples + darmstadt_test_samples

# samples = automatic_test.load_samples('../data/training_data/samples.pickle')
# # samples = automatic_test.normalize_features(samples)
# select_label_method(samples, 'y_distances')
# train_samples, test_samples = automatic_test.get_partitioned_samples(samples, 0.8)
# #automatic_test.test([rf_algo], train_samples, test_samples, cross_validation=False)
automatic_test.train([rf_algo], train_samples)
results = automatic_test.predict_all_estimators([rf_algo], test_samples)

for sample, prediction, predictions_all_estimators in zip(test_samples, results[rf_algo]['predictions'], results[rf_algo]['predictions_all_estimators']):
    predicted_distances = [pred[0] for pred in predictions_all_estimators]


    heatmap = get_heatmap_from_polar_all_predictors(predicted_distances, sample['geometry']['curve_secant'], sample['X'][_feature_types.index('intersection_angle')])

    # half_angle_vec = get_half_angle_vec(sample['geometry']['exit_line'], sample['X'][_feature_types.index('intersection_angle')])
    # heatmap = get_heatmap_from_distances_all_predictors(predicted_distances,
    #                                                 sample['geometry']['entry_line'],
    #                                                 sample['geometry']['exit_line'],
    #                                                 half_angle_vec)
    # plot_intersection(sample, predicted_distances, heatmap=heatmap, orientation="curve-secant")
    plot_intersection(sample, [prediction], rgbcolors=['b'], heatmap=heatmap, orientation="curve-secant")
Esempio n. 4
0
]

rf_algo_distances = regressors.RandomForestAlgorithm(feature_list)
samples_distances = automatic_test.load_samples('../data/training_data/samples.pickle')
# samples = automatic_test.normalize_features(samples)
select_label_method(samples_distances, 'y_distances')
train_sample_sets_distances, test_sample_sets_distances = automatic_test.get_cross_validation_samples(samples_distances, 0.8, 5)

rf_algo_radii = regressors.RandomForestAlgorithm(feature_list)
samples_radii = automatic_test.load_samples('../data/training_data/samples.pickle')
# samples = automatic_test.normalize_features(samples)
select_label_method(samples_radii, 'y_radii')
train_sample_sets_radii, test_sample_sets_radii = automatic_test.get_cross_validation_samples(samples_radii, 0.8, 5)

for train_samples_distances, test_samples_distances, train_samples_radii, test_samples_radii in zip(train_sample_sets_distances, test_sample_sets_distances, train_sample_sets_radii, test_sample_sets_radii):
    automatic_test.train([rf_algo_distances], train_samples_distances)
    results_distances = automatic_test.predict_all_estimators([rf_algo_distances], test_samples_distances)

    automatic_test.train([rf_algo_radii], train_samples_radii)
    results_radii = automatic_test.predict_all_estimators([rf_algo_radii], test_samples_radii)

    for sample, prediction, predictions_all_estimators, prediction_radii in zip(test_samples_distances, results_distances[rf_algo_distances]['predictions'], results_distances[rf_algo_distances]['predictions_all_estimators'], results_radii[rf_algo_radii]['predictions']):
        automatic_test.output_sample_features(sample, rf_algo_distances.features)
        predicted_distances = [pred[0] for pred in predictions_all_estimators]
        half_angle_vec = get_half_angle_vec(sample['geometry']['exit_line'], sample['X'][_feature_types.index('intersection_angle')])
        heatmap = get_heatmap_from_distances_all_predictors(predicted_distances,
                                                        sample['geometry']['entry_line'],
                                                        sample['geometry']['exit_line'],
                                                        half_angle_vec)
        # plot_intersection(sample, predicted_distances, heatmap=heatmap, orientation="curve-secant")
        plot_intersection(  sample,