Skip to content
Snippets Groups Projects
Commit 214500a0 authored by Sören Henning's avatar Sören Henning
Browse files

Update Jupyter notebooks and dependencies

parent 279b98df
No related branches found
No related tags found
No related merge requests found
Pipeline #17219 skipped
FROM jupyter/base-notebook:python-3.8 FROM jupyter/base-notebook:python-3.10
COPY . /home/jovyan COPY . /home/jovyan
... ...
......
...@@ -19,9 +19,8 @@ In general, the Theodolite Analysis Jupyter notebooks should be runnable by any ...@@ -19,9 +19,8 @@ In general, the Theodolite Analysis Jupyter notebooks should be runnable by any
we provide introductions for running notebooks with Docker and with Visual Studio Code. These intoduction may also be we provide introductions for running notebooks with Docker and with Visual Studio Code. These intoduction may also be
a good starting point for using another service. a good starting point for using another service.
For analyzing and visualizing benchmark results, either Docker or a Jupyter installation with Python 3.7 or 3.8 is For analyzing and visualizing benchmark results, either Docker or a Jupyter installation with Python 3.10 is
required (e.g., in a virtual environment). **Please note that Python 3.9 seems not to be working as not all our required (e.g., in a virtual environment).
dependencies are ported to Python 3.9 yet.**
### Running with Docker ### Running with Docker
...@@ -39,7 +38,7 @@ docker run --rm -p 8888:8888 -v "$PWD/../results":/home/jovyan/results -v "$PWD/ ...@@ -39,7 +38,7 @@ docker run --rm -p 8888:8888 -v "$PWD/../results":/home/jovyan/results -v "$PWD/
### Running with Visual Studio Code ### Running with Visual Studio Code
The [Visual Studio Code Documentation](https://code.visualstudio.com/docs/python/jupyter-support) shows to run Jupyter The [Visual Studio Code Documentation](https://code.visualstudio.com/docs/python/jupyter-support) shows to run Jupyter
notebooks with Visual Studio Code. For our notebooks, Python 3.7 or newer is required (e.g., in a virtual environment). notebooks with Visual Studio Code. For our notebooks, Python 3.10 or newer is required (e.g., in a virtual environment).
Moreover, they require some Python libraries, which can be installed by: Moreover, they require some Python libraries, which can be installed by:
```sh ```sh
... ...
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
import os import os
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from sklearn.linear_model import LinearRegression from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib import matplotlib
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
directory = '<path-to>/results' directory = '<path-to>/results'
#filename = 'exp1002_uc3_75000_1_totallag.csv' #filename = 'exp1002_uc3_75000_1_totallag.csv'
filename = 'exp1002_uc3_50000_2_totallag.csv' filename = 'exp1002_uc3_50000_2_totallag.csv'
warmup_sec = 60 warmup_sec = 60
threshold = 2000 #slope threshold = 2000 #slope
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
df = pd.read_csv(os.path.join(directory, filename)) df = pd.read_csv(os.path.join(directory, filename))
input = df.iloc[::3] input = df.iloc[::3]
#print(input) #print(input)
input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp'] input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']
#print(input) #print(input)
#print(input.iloc[0, 'timestamp']) #print(input.iloc[0, 'timestamp'])
regress = input.loc[input['sec_start'] >= warmup_sec] # Warm-Up regress = input.loc[input['sec_start'] >= warmup_sec] # Warm-Up
#regress = input #regress = input
#input.plot(kind='line',x='timestamp',y='value',color='red') #input.plot(kind='line',x='timestamp',y='value',color='red')
#plt.show() #plt.show()
X = regress.iloc[:, 4].values.reshape(-1, 1) # values converts it into a numpy array X = regress.iloc[:, 3].values.reshape(-1, 1) # values converts it into a numpy array
Y = regress.iloc[:, 3].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column Y = regress.iloc[:, 2].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column
linear_regressor = LinearRegression() # create object for the class linear_regressor = LinearRegression() # create object for the class
linear_regressor.fit(X, Y) # perform linear regression linear_regressor.fit(X, Y) # perform linear regression
Y_pred = linear_regressor.predict(X) # make predictions Y_pred = linear_regressor.predict(X) # make predictions
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
print(linear_regressor.coef_) print(linear_regressor.coef_)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
plt.style.use('ggplot') plt.style.use('ggplot')
plt.rcParams['axes.facecolor']='w' plt.rcParams['axes.facecolor']='w'
plt.rcParams['axes.edgecolor']='555555' plt.rcParams['axes.edgecolor']='555555'
#plt.rcParams['ytick.color']='black' #plt.rcParams['ytick.color']='black'
plt.rcParams['grid.color']='dddddd' plt.rcParams['grid.color']='dddddd'
plt.rcParams['axes.spines.top']='false' plt.rcParams['axes.spines.top']='false'
plt.rcParams['axes.spines.right']='false' plt.rcParams['axes.spines.right']='false'
plt.rcParams['legend.frameon']='true' plt.rcParams['legend.frameon']='true'
plt.rcParams['legend.framealpha']='1' plt.rcParams['legend.framealpha']='1'
plt.rcParams['legend.edgecolor']='1' plt.rcParams['legend.edgecolor']='1'
plt.rcParams['legend.borderpad']='1' plt.rcParams['legend.borderpad']='1'
#filename = f"exp{exp_id}_{benchmark}_{dim_value}_{instances}" #filename = f"exp{exp_id}_{benchmark}_{dim_value}_{instances}"
t_warmup = input.loc[input['sec_start'] <= warmup_sec].iloc[:, 4].values t_warmup = input.loc[input['sec_start'] <= warmup_sec].iloc[:, 3].values
y_warmup = input.loc[input['sec_start'] <= warmup_sec].iloc[:, 3].values y_warmup = input.loc[input['sec_start'] <= warmup_sec].iloc[:, 2].values
plt.figure() plt.figure()
#plt.figure(figsize=(4, 3)) #plt.figure(figsize=(4, 3))
plt.plot(X, Y, c="#348ABD", label="observed") plt.plot(X, Y, c="#348ABD", label="observed")
#plt.plot(t_warmup, y_warmup) #plt.plot(t_warmup, y_warmup)
plt.plot(X, Y_pred, c="#E24A33", label="trend") # color='red') plt.plot(X, Y_pred, c="#E24A33", label="trend") # color='red')
#348ABD, 7A68A6, A60628, 467821, CF4457, 188487, E24A33 #348ABD, 7A68A6, A60628, 467821, CF4457, 188487, E24A33
plt.gca().yaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, pos: '%1.0fK' % (x * 1e-3))) plt.gca().yaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, pos: '%1.0fK' % (x * 1e-3)))
plt.ylabel('queued messages') plt.ylabel('queued messages')
plt.xlabel('seconds since start') plt.xlabel('seconds since start')
plt.legend() plt.legend()
#ax.set_ylim(ymin=0) #ax.set_ylim(ymin=0)
#ax.set_xlim(xmin=0) #ax.set_xlim(xmin=0)
plt.savefig("plot.pdf", bbox_inches='tight') plt.savefig("plot.pdf", bbox_inches='tight')
``` ```
... ...
......
jupyter==1.0.0 jupyter==1.1.1
matplotlib==3.2.0 matplotlib==3.10.0
pandas==1.0.1 pandas==2.2.3
scikit-learn==1.0.2 scikit-learn==1.0.2
numpy==1.23.1 numpy==1.26.4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment