1
0
Fork 0
mirror of https://github.com/Findus23/collision-analyisis-and-interpolation.git synced 2024-09-19 15:13:50 +02:00

changes for the presentation

This commit is contained in:
Lukas Winkler 2019-04-18 10:50:57 +02:00
parent cb8080a20b
commit 2a94569a3a
Signed by: lukas
GPG key ID: 54DE4D798D244853
7 changed files with 24 additions and 28 deletions

3
.gitignore vendored
View file

@ -5,4 +5,5 @@ __pycache__/
*.hd5
*.png
logs/
.ipynb_checkpoints/
.ipynb_checkpoints/
*.pdf

View file

@ -25,8 +25,9 @@ X = np.array([[s.mcode, s.wpcode, s.wtcode, s.gammacode, s.alphacode, s.vcode] f
scaler = StandardScaler()
scaler.fit(X)
x = scaler.transform(X)
print(x)
print(x.shape)
Y = np.array([s.water_retention_both for s in train_data])
print(Y.shape)
X_test = np.array([[s.mcode, s.wpcode, s.wtcode, s.gammacode, s.alphacode, s.vcode] for s in test_data])
Y_test = np.array([s.water_retention_both for s in test_data])
tbCallBack = keras.callbacks.TensorBoard(log_dir='./logs', histogram_freq=0, batch_size=32, write_graph=True,
@ -34,21 +35,19 @@ tbCallBack = keras.callbacks.TensorBoard(log_dir='./logs', histogram_freq=0, bat
embeddings_layer_names=None, embeddings_metadata=None, embeddings_data=None,
update_freq='epoch')
if os.path.exists("model.hd5"):
if os.path.exists("model.hd5") and False:
model = load_model("model.hd5")
else:
model = Sequential()
model.add(Dense(6, input_dim=6, kernel_initializer='normal', activation='relu'))
model.add(Dense(3, kernel_initializer='normal', activation='relu'))
model.add(Dense(4, kernel_initializer='normal', activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_squared_error', optimizer='adam')
model.summary()
plot_model(model, "model.png", show_shapes=True, show_layer_names=True)
model.fit(x, Y, epochs=200, callbacks=[tbCallBack], validation_split=0.05)
model.fit(x, Y, epochs=200, callbacks=[tbCallBack], validation_split=0.02)
loss = model.evaluate(X_test, Y_test)
print(loss)
@ -73,5 +72,5 @@ outgrid = np.reshape(testoutput, (100, 100))
plt.pcolormesh(xgrid, ygrid, outgrid, cmap="Blues", vmin=0, vmax=1)
plt.colorbar()
plt.savefig("keras.png")
plt.savefig("keras.png", transparent=True)
plt.show()

View file

@ -2,6 +2,7 @@ import numpy as np
from matplotlib import pyplot as plt
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
np.set_printoptions(linewidth=1000, edgeitems=4)
@ -33,6 +34,9 @@ print(pca.explained_variance_) # n largest eigenvalues of covariance matrix
print(pca.explained_variance_ratio_, "(as ratio)")
print_heading("covariance") ############################
cov = np.cov(x.T)
print(pca.get_covariance())
print(np.allclose(pca.get_covariance(),cov))
print(pca.get_covariance().shape) # eigenvectors
print(pca.get_covariance())
@ -60,7 +64,7 @@ plt.show()
# plot correclation matrix
cov = pca.get_covariance()
plt.matshow(cov)
plt.xticks(range(len(labels)), labels,rotation=90)
plt.xticks(range(len(labels)), labels, rotation=90)
plt.yticks(range(len(labels)), labels)
plt.colorbar()

View file

@ -13,7 +13,6 @@ matplotlib==3.0.2
mock==2.0.0
numpy==1.16.1
pbr==5.1.2
pkg-resources==0.0.0
protobuf==3.6.1
pydot==1.4.1
pyparsing==2.3.1

View file

@ -46,9 +46,11 @@ class SimulationList:
def as_matrix(self):
entrylist = []
for sim in self.simlist:
entrylist.append([sim.mcode, sim.wpcode, sim.wtcode, sim.gammacode, sim.alphacode, sim.vcode,sim.water_retention_both])
entrylist.append(
[sim.mcode, sim.wpcode, sim.wtcode, sim.gammacode, sim.alphacode, sim.vcode, sim.water_retention_both]
)
return np.asarray(entrylist)
@property
def matrix_labels(self):
return ["mcode", "wpcode", "wtcode", "gammacode", "alphacode", "vcode"]
return ["mcode", "wpcode", "wtcode", "gammacode", "alphacode", "vcode", "water retention"]

View file

@ -40,7 +40,7 @@ mcode_default, gamma_default, wt_default, wp_default = [24.0, 1, 10.0, 10.0]
datagrid = get_data(mcode_default, gamma_default, wt_default, wp_default)
mesh = plt.pcolormesh(grid_x, grid_y, datagrid, cmap="Blues", vmin=0, vmax=1) # type:QuadMesh
plt.colorbar()
print(type(mesh))
axcolor = 'lightgoldenrodyellow'
@ -75,15 +75,4 @@ s_mcode.on_changed(update)
s_wp.on_changed(update)
s_wt.on_changed(update)
# resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
# button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
#
# def reset(event):
# sfreq.reset()
# samp.reset()
#
#
# button.on_clicked(reset)
plt.show()

View file

@ -27,8 +27,10 @@ plt.title("m={:3.0f}, gamma={:3.1f}, wt={:2.0f}, wp={:2.0f}\n".format(mcode, gam
# plt.contourf(grid_x, grid_y, grid_c, N, cmap="Blues", vmin=0, vmax=1)
plt.pcolormesh(grid_x, grid_y, grid_c, cmap="Blues", vmin=0, vmax=1)
plt.colorbar().set_label("test")
plt.scatter(data[:, 0], data[:, 1], c="black", cmap="Blues")
plt.savefig("vis.png")
plt.colorbar().set_label("water retention")
# plt.scatter(data[:, 0], data[:, 1], c=values, cmap="Blues")
plt.xlabel("impact angle $\\alpha$")
plt.ylabel("velocity $v$")
plt.tight_layout()
plt.savefig("vis.png",transparent=True)
plt.show()