# "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")
"maxspeed": "30", "name": "Heinheimer Stra\u00dfe" }, "exit_way": { "highway": "residential", "maxspeed": "30", "name": "Vogelsbergstra\u00dfe" } } # Create number of LineString serving as way data angles = np.linspace(-3*np.pi/8, 11*np.pi/8, 15) scale = 50.0 coords = [[(0,0),(0,1*scale),(np.cos(a)*scale,(1+np.sin(a))*scale)] for a in angles] labels = ["Test way %.2f°" % (a/np.pi*180.) for a in angles] lines = [LineString(c) for c in coords] test_samples = [] # Create synthetic samples for line, label in zip(lines, labels): int_sit, osm = create_intersection_data(line, 0.5, normalized=True, tags=tags) sample = create_sample(int_sit, osm, label, output="console") test_samples.append(sample) train_samples = automatic_test.load_samples('../data/training_data/samples_23_09_15/samples.pickle') # train_samples = automatic_test.normalize_features(samples) # Load algorithm with train samples and test the synthetic ones rf_algo = regressors.RandomForestAlgorithm() automatic_test.train([rf_algo], train_samples) results = automatic_test.predict([rf_algo], test_samples) automatic_test.show_intersection_plot(results, test_samples, orientation="curve-secant")
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")
# Simple test with RandomForestRegressor and RandomForestClassifier import sys 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) #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) automatic_test.show_intersection_plot(results, test_samples, which_samples="best-worst-case")