Esempio n. 1
0
    # "track_distance_projected_along_half_angle_vec_exit",
    "lane_distance_along_curve_secant_entry",   # Distance of lane center line to curve secant ceter point at 0 degree angle
    # "lane_distance_along_curve_secant_exit",    # 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?
    "curvature_entry",                          # Curvature of entry way over INT_DIST
    # "curvature_exit",                           # Curvature of exit way over INT_DIST
    "vehicle_speed_entry",                      # Measured vehicle speed on entry way at INT_DIST
    # "vehicle_speed_exit",                       # Measured vehicle speed on exit way at INT_DIST
    # "lane_count_entry",                         # Total number of lanes in entry way
    # "lane_count_exit",                          # Total number of lanes in exit way
    # "has_right_of_way",                         # Does the vehicle with the respective manoeuver have right of way at the intersection?
    "curve_secant_dist"
]

kitti_samples = automatic_test.load_samples('../data/training_data/samples_kitti/samples.pickle')
darmstadt_samples = automatic_test.load_samples('../data/training_data/samples_darmstadt/samples.pickle')
samples = kitti_samples + darmstadt_samples
select_label_method(samples, 'y_distances')
random.shuffle(samples)
sub_samples, test_samples = automatic_test.get_partitioned_samples(samples, 0.8)
train_samples, validation_samples = automatic_test.get_partitioned_samples(sub_samples, 0.75)
# train_samples, validation_samples = automatic_test.get_cross_validation_samples(sub_samples, 4)

rf_algo = regressors.RandomForestAlgorithm(feature_list, single_target_variable=False, random_state=random, n_estimators=27, max_features=12, max_leaf_nodes=5)
rf_algo2 = regressors.RandomForestAlgorithm(feature_list2, single_target_variable=False, random_state=random, n_estimators=35, max_features=5, max_leaf_nodes=8)
algos = [rf_algo, rf_algo2]
results = automatic_test.test(algos, train_samples, test_samples, cross_validation=False)
# automatic_test.show_intersection_plot(results, test_samples, which_samples="best-worst-case", orientation="curve-secant")
automatic_test.show_intersection_plot(results, validation_samples, which_samples="all", orientation="curve-secant")
Esempio n. 2
0
#!/usr/bin/python
#coding:utf-8
# Comparing random forest and Extra Trees algorithm
import sys
sys.path.append('../')
import automatic_test
import regressors
import reference_implementations
from extract_features import _feature_types

feature_list = _feature_types

rf_algo = regressors.RandomForestAlgorithm(feature_list)
et_algo = regressors.ExtraTreesAlgorithm(feature_list)
algos = [rf_algo, et_algo]
samples = automatic_test.load_samples('../data/training_data/samples_23_09_15/samples.pickle')
samples = automatic_test.normalize_features(samples)
train_sample_sets, test_sample_sets = automatic_test.get_cross_validation_samples(samples, 0.8, 5)
automatic_test.test(algos, train_sample_sets, test_sample_sets, cross_validation=True)
# results = automatic_test.predict(algos, test_samples)
# automatic_test.show_intersection_plot(results, test_samples, which_samples="best-worst-case")
Esempio n. 3
0
    "maxspeed_entry",                           # Allowed maximum speed on entry way
    "maxspeed_exit",                            # Allowed maximum speed on exit way
    "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?
    "curvature_entry",                          # Curvature of entry way over INT_DIST
    "curvature_exit",                           # Curvature of exit way over INT_DIST
    "bicycle_designated_entry",                 # Is there a designated bicycle way in the entry street?
    "bicycle_designated_exit",                  # Is there a designated bicycle way in the exit street?
    "lane_count_entry",                         # Total number of lanes in entry way
    "lane_count_exit",                          # Total number of lanes in exit way
    "has_right_of_way",                         # Does the vehicle with the respective manoeuver have right of way at the intersection?
    "curve_secant_dist"                         # Shortest distance from curve secant to intersection center
]

rf_algo_radii = regressors.RandomForestAlgorithm(feature_list)
rf_algo_distances = regressors.RandomForestAlgorithm(feature_list)
samples_radii = automatic_test.load_samples('../data/training_data/samples.pickle')
# samples_radii = automatic_test.normalize_features(samples)
samples_distances = automatic_test.load_samples('../data/training_data/samples.pickle')
# samples_distances = automatic_test.normalize_features(samples_distances)
select_label_method(samples_distances, 'y_distances')
train_samples_radii, test_samples_radii = automatic_test.get_cross_validation_samples(samples_radii, 0.7, 5)
train_samples_distances, test_samples_distances = automatic_test.get_cross_validation_samples(samples_distances, 0.7, 5)
automatic_test.test([rf_algo_radii], train_samples_radii, test_samples_radii, cross_validation=True)
automatic_test.test([rf_algo_distances], train_samples_distances, test_samples_distances, cross_validation=True)
# automatic_test.train([rf_algo_distances], train_samples_distances)
# results = automatic_test.predict([rf_algo_distances], test_samples_distances)
# automatic_test.show_intersection_plot(results, test_samples_distances, which_samples="all")
Esempio n. 4
0
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
    "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
    "curvature_entry",
    "curvature_exit",
    "curve_secant_dist"                         # Shortest distance from curve secant to intersection center
]
sample_files = [
    "samples_10.pickle",
    "samples_20.pickle",
    "samples_30.pickle",
    "samples_40.pickle",
    "samples_50.pickle"
]

for fn in sample_files:
    rf_algo = regressors.RandomForestAlgorithm(feature_list)
    samples = automatic_test.load_samples('../data/training_data/samples_INT_DIST/'+fn)
    samples = automatic_test.normalize_features(samples)
    train_sample_sets, test_sample_sets = automatic_test.get_cross_validation_samples(samples, 0.8, 5)
    automatic_test.test([rf_algo], train_sample_sets, test_sample_sets, cross_validation=True)
# results = automatic_test.predict(algos, test_samples)
# automatic_test.show_intersection_plot(results, test_samples, which_samples="best-worst-case")
Esempio n. 5
0

    # fig = plt.figure()
    # sns.plt.hold(True)
    for i in range(curvatures.shape[0]):
        handle, = ax.plot(line_dists[i], np.degrees(curvatures[i]), color=color, linestyle='-')
    return handle # Only need one
    # plt.title(title)
    # sns.plt.show()

def show_bar_plot():
    pass

if __name__ == "__main__":

    dataset_samples = [("KITTI + Karlsruhe", automatic_test.load_samples("data/training_data/samples_analysis/samples_kitti.pickle")),
                        ("Darmstadt", automatic_test.load_samples("data/training_data/samples_analysis/samples_darmstadt.pickle"))]

    sns.set_style("whitegrid", {"legend.frameon":True})
    # Intersection angles
    figure1, axes1 = sns.plt.subplots(1, 2, sharey=True)
    for i, (name, samples) in enumerate(dataset_samples):
        ax = axes1[i]
        # sns.set_style("whitegrid")
        intersection_angles = list(get_array_from_feature(samples, 'intersection_angle')/(np.pi)*180.0)
        left_turn_count = len([ia for ia in intersection_angles if ia >= 0.])
        right_turn_count = len([ia for ia in intersection_angles if ia < 0.])
        print "%s: links: %d/%d rechts: %d/%d" % (name, left_turn_count, len(intersection_angles), right_turn_count, len(intersection_angles))
        sns.distplot(intersection_angles, bins=20, kde=False, rug=True, ax=ax)
        # sns.plt.bar(intersection_angles, bins=20)
        # ax.set_xlabel(u"Kreuzungswinkel [°]")
Esempio n. 6
0
    "maxspeed_exit",  # Allowed maximum speed on exit way
    "lane_distance_entry_projected_normal",
    "lane_distance_exit_projected_normal",
    "oneway_entry",  # Is entry way a oneway street?
    "oneway_exit",  # Is exit way a oneway street?
    "curvature_entry",  # Curvature of entry way over INT_DIST
    "curvature_exit",  # Curvature of exit way over INT_DIST
    "bicycle_designated_entry",  # Is there a designated bicycle way in the entry street?
    "bicycle_designated_exit",  # Is there a designated bicycle way in the exit street?
    "lane_count_entry",  # Total number of lanes in entry way
    "lane_count_exit",  # Total number of lanes in exit way
    "has_right_of_way",  # Does the vehicle with the respective manoeuver have right of way at the intersection?
    "curve_secant_dist",  # Shortest distance from curve secant to intersection center
]

kitti_samples = automatic_test.load_samples("../data/training_data/samples_15_10_08/samples.pickle")
darmstadt_samples = automatic_test.load_samples("../data/training_data/samples_15_10_20_darmstadt/samples.pickle")
extract_features.select_label_method(kitti_samples, "y_distances")
extract_features.select_label_method(darmstadt_samples, "y_distances")
train_kitti, test_kitti = automatic_test.get_partitioned_samples(kitti_samples, 0.7)
train_darmstadt, test_darmstadt = automatic_test.get_partitioned_samples(darmstadt_samples, 0.7)
train_samples = train_kitti + train_darmstadt
test_samples = test_kitti + test_darmstadt
rf_algo = regressors.RandomForestAlgorithm(feature_list)

print "###### Non-rectified data ######"
print "------ Only KITTI ------"
automatic_test.test([rf_algo], train_kitti, test_kitti, cross_validation=False)
print "------ KITTI + Darmstadt ------"
automatic_test.test([rf_algo], train_samples, test_samples, cross_validation=False)
Esempio n. 7
0
    "lane_distance_exit_projected_normal",
    "oneway_entry",                             # Is entry way a oneway street?
    "oneway_exit",                              # Is exit way a oneway street?
    "curvature_entry",                          # Curvature of entry way over INT_DIST
    "curvature_exit",                           # Curvature of exit way over INT_DIST
    "bicycle_designated_entry",                 # Is there a designated bicycle way in the entry street?
    "bicycle_designated_exit",                  # Is there a designated bicycle way in the exit street?
    "lane_count_entry",                         # Total number of lanes in entry way
    "lane_count_exit",                          # Total number of lanes in exit way
    "has_right_of_way",                         # Does the vehicle with the respective manoeuver have right of way at the intersection?
    "curve_secant_dist"                         # Shortest distance from curve secant to intersection center
]

rf_algo = regressors.RandomForestAlgorithm(feature_list)
is_algo = reference_implementations.InterpolatingSplineAlgorithm()
kitti_samples = automatic_test.load_samples('../data/training_data/samples_15_10_12_rectified/samples.pickle')
darmstadt_samples = automatic_test.load_samples('../data/training_data/samples_15_10_20_darmstadt_rectified/samples.pickle')
select_label_method(kitti_samples, 'y_distances')
select_label_method(darmstadt_samples, 'y_distances')
train_samples_kitti, test_samples_kitti = automatic_test.get_partitioned_samples(kitti_samples, 0.7)
train_samples_darmstadt, test_samples_darmstadt = automatic_test.get_partitioned_samples(darmstadt_samples, 0.7)
train_samples = train_samples_kitti + train_samples_darmstadt
test_samples = test_samples_darmstadt + test_samples_kitti
automatic_test.train([rf_algo], train_samples)
results = automatic_test.predict_all_estimators([rf_algo], test_samples)
is_results = automatic_test.predict([is_algo], test_samples)

for sample, rf_prediction, rf_predictions_all_estimators, is_prediction in zip(test_samples,
                                                            results[rf_algo]['predictions'],
                                                            results[rf_algo]['predictions_all_estimators'],
                                                            is_results[is_algo]['predictions']):