<jupyter_start><jupyter_text>Task 4 - Fire Evacuation Planning for the MI Building<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import math

%matplotlib inline
# load the data sets
train_X = np.load('FireEvac_train_set.npy')
test_X = np.load('FireEvac_test_set.npy')
# plot the training set
plt.scatter(train_X[:,0],train_X[:,1]);
plt.title('Training set');
plt.xlabel('x');
plt.ylabel('y');
# plot the test set
plt.scatter(test_X[:,0],test_X[:,1]);
plt.title('Test set');
plt.xlabel('x');
plt.ylabel('y');
test_X.max(0) # little help to choose the upper bounds for the random generator
# get p(x) - here by simple random generation
np.random.seed(100)# 100 is the seed used for the picture in the report, try 10 and 1 for drastic changes
x_bound = 190 # upper bound for the x coordinate
y_bound = 110 # upper bound for the y coordinate
num_samples = 1000
p_x_simple = np.random.rand(num_samples, 2) * np.array([x_bound, y_bound])
np.shape(p_x_simple)# should be (num_samples, 2) i.e. 1000 samples of (x,y)-coordinates
# plot the samples - will be totally random, no MI building at all
plt.scatter(p_x_simple[:,0],p_x_simple[:,1]);
plt.title('Random coordinate sampling with 1000 samples');
plt.xlabel('x');
plt.ylabel('y');
# count the number of persons in the measurement area
counter = 0
for x,y in p_x_simple:
    if 130 <= x <= 150 and 50 <= y <= 70:
        counter += 1
print('Number of persons in the measurement area: '+str(counter))
# calculate the expected number of samples that need to be drawn in order to have 100 persons in the measurement area
crit_num_persons = 100
crit_num_samples = math.ceil(crit_num_persons * num_samples / counter)
print('With the given distribution '+str(crit_num_samples)+' samples are needed to reach '+str(crit_num_persons)+' persons in the measurement area.')<jupyter_output>With the given distribution 5556 samples are needed to reach 100 persons in the measurement area.
{'fraction_non_alphanumeric': 0.11260330578512397, 'fraction_numerical': 0.03202479338842975, 'mean_word_length': 5.330065359477124, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '223953', 'license': 'MIT', 'n_tokens_mistral': 685, 'n_tokens_neox': 620, 'n_words': 229, 'path': 'Exercise_4/Task_4.ipynb', 'repo_name': 'Schnursenkel/mlcms_group_g', 'size': '1936'}