Commit bcdfb1c5 authored by Uwe Köckemann's avatar Uwe Köckemann
Browse files

Experiments added for crime notebook.

parent 94709cc2
......@@ -2,9 +2,21 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'GBTree' from 'scikit_learn_wrapper' (/home/uwe/Work/Projects/moving-targets/aiddl-project/python/moving_target/scikit_learn_wrapper.py)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-f7efb1359eb3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtools\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mCsvLoader\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mutils\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdidi_c\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 36\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mscikit_learn_wrapper\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGBTree\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 37\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mscikit_learn_wrapper\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSciKitLearnFunction\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mscikit_learn_wrapper\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msplitAiddlMlProblem\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'GBTree' from 'scikit_learn_wrapper' (/home/uwe/Work/Projects/moving-targets/aiddl-project/python/moving_target/scikit_learn_wrapper.py)"
]
}
],
"source": [
"from abc import ABC, abstractmethod\n",
"\n",
......@@ -37,6 +49,7 @@
"\n",
"from moving_target_cplex import MovingTargetRegCplex\n",
"from moving_target_cplex import MovingTargetClsCplex\n",
"from factory import get_problem\n",
"from preprocessing import OneHotEncoder\n",
"from tools import CsvLoader\n",
"from utils import didi_c\n",
......
......@@ -487,7 +487,20 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.7.10"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
......
......@@ -128,7 +128,7 @@ class MovingTarget(ABC):
cval = c[2].real_value()
C.append((ctype, cvar, cval))
print("Converted constraints: ", C)
#print("Converted constraints: ", C)
return C
......
......@@ -84,7 +84,7 @@ class MovingTargetClsCplex(MovingTarget):
self.constraints.append(cstr)
print("Constraint added: " + str(cstr))
#print("Constraint added: " + str(cstr))
def m_alpha(self, M, L, y_k, alpha):
......@@ -133,7 +133,7 @@ class MovingTargetClsCplex(MovingTarget):
for c in self.constraints:
sat = sat & c.is_satisfied(*d)
print("Constraint satisfaction: " + str(sat))
#print("Constraint satisfaction: " + str(sat))
return sat
def solve_ext(self, M):
......@@ -185,7 +185,7 @@ class MovingTargetClsCplex(MovingTarget):
self.n_classes = len(self.classes.keys())
self.n_points = len(y)
print("Points: %d, Classes: %d" % (self.n_points, self.n_classes))
#print("Points: %d, Classes: %d" % (self.n_points, self.n_classes))
mod.binary_var_matrix(keys1=self.n_points,
keys2=self.n_classes,
name='y')
......@@ -209,8 +209,8 @@ class MovingTargetClsCplex(MovingTarget):
try:
mod.check_has_solution()
print("Solver status: " + mod.solve_details.status)
print("MIP Gap: {:.3f} %".format(100 * mod.solve_details.mip_relative_gap))
#print("Solver status: " + mod.solve_details.status)
#print("MIP Gap: {:.3f} %".format(100 * mod.solve_details.mip_relative_gap))
except DOcplexException as err:
# self.logger.error("Model infeasible!")
mod.export_as_lp(path='./', basename='infeasible')
......@@ -285,7 +285,7 @@ class MovingTargetRegCplex(MovingTarget):
self.constraints.append(cstr)
print("Constraint added: " + str(cstr))
#print("Constraint added: " + str(cstr))
def m_alpha(self, M, L, y_k, alpha):
......@@ -331,7 +331,7 @@ class MovingTargetRegCplex(MovingTarget):
for c in self.constraints:
sat = sat & c.is_satisfied(*d)
print("Constraint satisfaction: " + str(sat))
# print("Constraint satisfaction: " + str(sat))
return sat
def solve_ext(self, M):
......@@ -376,8 +376,8 @@ class MovingTargetRegCplex(MovingTarget):
try:
mod.check_has_solution()
print("Solver status: " + mod.solve_details.status)
print("MIP Gap: {:.3f} %".format(100 * mod.solve_details.mip_relative_gap))
#print("Solver status: " + mod.solve_details.status)
#print("MIP Gap: {:.3f} %".format(100 * mod.solve_details.mip_relative_gap))
except DOcplexException as err:
# self.logger.error("Model infeasible!")
mod.export_as_lp(path='./', basename='infeasible')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment