Skip to content

Instantly share code, notes, and snippets.

View Alexander-Schiendorfer's full-sized avatar

Alexander Schiendorfer Alexander-Schiendorfer

View GitHub Profile
predictions = model.predict(test_images)
predictions = np.argmax(predictions, axis=1)
conf_matrix = confusion_matrix(np.argmax(test_labels, axis=1), predictions)
# just for better presentation - but store original values
default_figsize = plt.rcParams['figure.figsize']
default_dpi = plt.rcParams['figure.dpi']
plt.rcParams['figure.figsize'] = [19, 12]
plt.rcParams['figure.dpi'] = 150
def compare_nearest_neighbors(self):
""" get nearest neighbor for every wrong labeled datapoint and compare feature values in one DataFrame """
results = []
for index, row in self.wrong_predictions.iterrows():
query_data_point = row[:-2]
query_data = row[:]
data_points = self.X_predictions.iloc[:, :-2]
# training für 10 epochen
history = model.fit(train_images, train_labels, batch_size=batch_size,
shuffle=True, epochs=n_epochs, validation_data = (test_images, test_labels))
import pandas as pd
pd.DataFrame(history.history).plot(figsize=(8,5))
plt.grid(True)
plt.gca().set_ylim(0, 1)
plt.show()
# first make sure to save the history ...
# let's actually fit our model
history = model.fit(train_images, train_labels, epochs=num_epochs, batch_size=batch_size)
# then, visualize the history
import pandas as pd
pd.DataFrame(history.history).plot(figsize=(8, 5))
plt.grid(True)
@Alexander-Schiendorfer
Alexander-Schiendorfer / carseq.dzn
Created June 14, 2020 11:41
Car Sequencing MiniZinc
nCarTypes = 6;
nOptions = 5;
requires = array2d(CarTypes, Options, [
true, false, true, true, false,
false, false, false, true, false,
false, true, false, false, true,
false, true, false, true, false,
true, false, false, false, false,
true, true, false, false, false]);
```matlab
include "classic_o.mzn"; % output of minibrass
include "soft_constraints/pvs_gen_search.mzn"; % for generic branch and bound
% the basic, "classic" CSP
set of int: NURSES = 1..3;
int: day = 1; int: night = 2; int:off = 3;
set of int: SHIFTS = {day,night,off};
array[NURSES] of var SHIFTS: n;
% A really simplistic over-constrained model
% X: {x,y,z} D_i = {1,2,3}, i in X
% * c1: x + 1 = y
% * c2: z = y + 2
% * c3: x + y <= 3
% -------------------------------------------
include "soft-constraints/soft_constraints.mzn"; % model additions for soft constraint business
include "soft-constraints/spd_worse.mzn"; % the actual isBetter predicate
include "soft-constraints/tpd_worse.mzn"; % the actual isBetter predicate
% a very minimal example to provoke isa: nullptr bug
% ---------------------------------
include "minisearch.mzn"; % include the search minisearch lite
set of int: range = 1..5;
var set of range: x;
predicate onlyEvens(var set of range: y) =
(
forall(r in y) (r mod 2 = 0)
% a very minimal example to provoke isa: nullptr bug
% ---------------------------------
set of int: range = 1..5;
var set of range: x;
predicate onlyEvens(var set of range: y) =
(
forall(r in y) (r mod 2 = 0)
);
% a very minimal example to provoke isa: nullptr bug
% ---------------------------------
set of int: range = 1..5;
var set of range: x;
predicate onlyEvens(var set of range: y) =
(
forall(r in y) (r mod 2 = 0)
);