Skip to content

Commit

Permalink
Debug for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mghasemi committed Feb 21, 2019
1 parent f620185 commit bfce654
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 44 deletions.
2 changes: 0 additions & 2 deletions SKSurrogate/NpyProximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
==================================
"""

from __future__ import print_function

Infinitesimal = 1e-7


Expand Down
5 changes: 4 additions & 1 deletion SKSurrogate/aml.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def Generate(self, l):
return words


from SKSurrogate.structsearch import Real, Integer, Categorical, HDReal, BoxSample
try:
from .structsearch import Real, Integer, Categorical, HDReal, BoxSample
except:
from SKSurrogate.structsearch import Real, Integer, Categorical, HDReal, BoxSample

default_config = {
# Classifiers
Expand Down
95 changes: 57 additions & 38 deletions SKSurrogate/mltrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
It also has built in capabilities to generate some typical plots and graph in machine learning.
"""

from peewee import *
try:
from peewee import *
except:
Model = type('Model', (object,), dict(Simple=lambda : 0.,))
SqliteDatabase = lambda x: None
from datetime import datetime

MLTRACK_DB = SqliteDatabase(None)
Expand Down Expand Up @@ -51,13 +55,16 @@ class Task(Model):
This table keeps basic information about the task on hand, e.g., the task name, a brief description,
target column, and columns to be ignored.
"""
task_id = IntegerField(primary_key=True, unique=True, null=False, default=1)
name = CharField(null=True)
description = TextField(null=True)
target = CharField(null=True)
ignore = CharField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
last_mod_date = DateTimeField(default=datetime.now, null=True)
try:
task_id = IntegerField(primary_key=True, unique=True, null=False, default=1)
name = CharField(null=True)
description = TextField(null=True)
target = CharField(null=True)
ignore = CharField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
last_mod_date = DateTimeField(default=datetime.now, null=True)
except:
pass

class Meta:
database = MLTRACK_DB
Expand All @@ -68,13 +75,16 @@ class MLModel(Model):
The class to generate the 'mlmodel` table in the SQLite db-file.
It stores the scikit-learn scheme of the model/pipeline, its parameters, etc.
"""
model_id = IntegerField(primary_key=True, unique=True, null=False)
task_id = ForeignKeyField(Task)
name = CharField(null=True)
model_str = TextField(null=True)
model_type = CharField(null=True)
parameters = BareField(null=True)
date_modified = DateTimeField(default=datetime.now, null=True)
try:
model_id = IntegerField(primary_key=True, unique=True, null=False)
task_id = ForeignKeyField(Task)
name = CharField(null=True)
model_str = TextField(null=True)
model_type = CharField(null=True)
parameters = BareField(null=True)
date_modified = DateTimeField(default=datetime.now, null=True)
except:
pass

class Meta:
database = MLTRACK_DB
Expand All @@ -85,20 +95,23 @@ class Metrics(Model):
The class to generate the 'metrics` table in the SQLite db-file.
This table stores the calculated metrics of each stored model.
"""
mwtrics_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
accuracy = FloatField(null=True)
auc = FloatField(null=True)
precision = FloatField(null=True)
recall = FloatField(null=True)
f1 = FloatField(null=True)
mcc = FloatField(null=True)
logloss = FloatField(null=True)
variance = FloatField(null=True)
max_error = FloatField(null=True)
mse = FloatField(null=True)
mae = FloatField(null=True)
r2 = FloatField(null=True)
try:
mwtrics_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
accuracy = FloatField(null=True)
auc = FloatField(null=True)
precision = FloatField(null=True)
recall = FloatField(null=True)
f1 = FloatField(null=True)
mcc = FloatField(null=True)
logloss = FloatField(null=True)
variance = FloatField(null=True)
max_error = FloatField(null=True)
mse = FloatField(null=True)
mae = FloatField(null=True)
r2 = FloatField(null=True)
except:
pass

class Meta:
database = MLTRACK_DB
Expand All @@ -109,10 +122,13 @@ class Saved(Model):
The class to generate the 'saved` table in the SQLite db-file.
It keeps the pickled version of a stored model that can be later recovered.
"""
pickle_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
pickle = BareField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
try:
pickle_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
pickle = BareField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
except:
pass

class Meta:
database = MLTRACK_DB
Expand All @@ -123,11 +139,14 @@ class Plots(Model):
The class to generate the 'plots` table in the SQLite db-file.
This table stores `matplotlib` plots associated to each model.
"""
plot_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
title = CharField(null=True)
plot = BareField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
try:
plot_id = IntegerField(primary_key=True, unique=True, null=False)
model_id = ForeignKeyField(MLModel)
title = CharField(null=True)
plot = BareField(null=True)
init_date = DateTimeField(default=datetime.now, null=True)
except:
pass

class Meta:
database = MLTRACK_DB
Expand Down
7 changes: 4 additions & 3 deletions SKSurrogate/structsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def sample(self, centre, cntrctn=1.):
:param cntrctn: `float` customized contraction factor
:return: `numpy.array` a new sample
"""
from random import uniform, randint, shuffle
from random import uniform, shuffle
from numpy import sqrt, array
flag = False
n = len(centre)
Expand Down Expand Up @@ -597,14 +597,15 @@ def __init__(self, a, b, **kwargs):
self.bound_tuple = tuple(self.bound_tuple)


from sklearn.model_selection._search import BaseSearchCV, check_cv
from sklearn.base import clone, is_classifier
from sklearn.metrics.scorer import check_scoring
from sklearn.model_selection._search import BaseSearchCV, check_cv
from sklearn.model_selection._validation import _fit_and_score

try:
from Optimithon import NumericDiff
except:
NumericDiff = type('NumericDiff', (object,), dict(Simple=lambda : 0.,))
NumericDiff = type('NumericDiff', (object,), dict(Simple=lambda: 0., ))
from numpy import inf


Expand Down

0 comments on commit bfce654

Please sign in to comment.