<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Aufgabe 2
Step1:  First we create a training set of size n_samples containing n_features each.
Step2:  Next we run a performance test on the created data set. Therefor we train a random forest classifier with n_est estimators multiple times and save the best time for later comparison. Each time we use a different number of jobs to train the classifier
Step3:  Finally we plot our results.
<ASSISTANT_TASK:>
Python Code:
# imports
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from timeit import default_timer as timer
import matplotlib.pyplot as plt
Explanation: Aufgabe 2: Classification
A short test to examine the performance gain when using multiple cores on sklearn's esemble classifier random forest.
Depending on the available system the maximum number of jobs to test and the sample size can be adjusted by changing the respective parameters.
End of explanation
n_samples = 200000
n_features = 20
X, y = make_classification(n_samples=n_samples, n_features=n_features)
Explanation: First we create a training set of size n_samples containing n_features each.
End of explanation
# parameter for performance test
n_est = 16
max_jobs = 8
best_in = 3
# performance test
measurements = []
i = 1
while i <= max_jobs:
    min_t = float("inf")  
    for j in range(best_in):
        rnd_forest_clf = RandomForestClassifier(n_estimators=n_est, n_jobs=i)
        start = timer()
        rnd_forest_clf.fit(X,y)
        stop = timer()
        min_t = min(min_t, stop - start)
    measurements.append(min_t)
    i += 1
Explanation: Next we run a performance test on the created data set. Therefor we train a random forest classifier with n_est estimators multiple times and save the best time for later comparison. Each time we use a different number of jobs to train the classifier
End of explanation
fig = plt.figure()
fig.suptitle('Visualization of the runtime depending on the number of used jobs.')
ax = fig.add_subplot(111)
ax.set_xlabel('used jobs')
ax.set_ylabel('runtime in seconds')
plt.xticks(range(1, max_jobs + 1), range(1, max_jobs + 1))
ax.plot(range(1, max_jobs + 1), measurements, 'ro')
plt.show()
Explanation: Finally we plot our results.
End of explanation
<END_TASK>