"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")
Beispiel #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")
Beispiel #3
0
N_tests = 10
training_samples_steps = np.arange(10, N_training_samples+1, 10)
all_training_errors = []
all_cv_errors = []
all_training_samples_sizes = []

for test_i in range(N_tests):
    print "====== Test number %d ======" % test_i
    random.shuffle(samples)
    cv_samples = samples[N_training_samples:]
    for training_samples_size in training_samples_steps:
        print "Training samples size:", training_samples_size
        training_samples = samples[:training_samples_size]

        automatic_test.train([rf_algo], training_samples)
        rs_train = automatic_test.get_result_statistics(automatic_test.predict([rf_algo], training_samples))
        rs_cv = automatic_test.get_result_statistics(automatic_test.predict([rf_algo], cv_samples))

        all_training_samples_sizes.append(training_samples_size)
        all_training_errors.append(rs_train[rf_algo]['mean_mse'])
        all_cv_errors.append(rs_cv[rf_algo]['mean_mse'])

training_errors = []
cv_errors = []
training_samples_sizes = []

# Flatten the results
for training_samples_size in training_samples_steps:
    indices = [i for i,x in enumerate(all_training_samples_sizes) if x == training_samples_size]

    training_samples_sizes.append(training_samples_size)