diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 60703d5..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -recursive-include ezmodel *.py \ No newline at end of file diff --git a/README.rst b/README.rst index 537abcc..942246c 100644 --- a/README.rst +++ b/README.rst @@ -146,14 +146,14 @@ Kriging import numpy as np from ezmodel.models.kriging import Kriging - from ezmodel.util.sample_from_func import sine_function + from ezmodel.util.sample_from_func import square_function model = Kriging(regr="linear", corr="gauss", ARD=False) # create some data to test this model on - X, y, _X, _y = sine_function(100, 20) + X, y, _X, _y = square_function(100, 20) # let the model fit the data model.fit(X, y) diff --git a/docs/github/README.template b/docs/github/README.template index 1494189..a67c0a0 100644 --- a/docs/github/README.template +++ b/docs/github/README.template @@ -1,4 +1,4 @@ -ezmodel - A common interface for models and model selection +ezmodel - A Common Interface for Models and Model Selection ==================================================================== For more information about our toolbox, users are encouraged to read our documentation. diff --git a/ezmodel/core/benchmark.py b/ezmodel/core/benchmark.py index 26966d4..c8c590c 100644 --- a/ezmodel/core/benchmark.py +++ b/ezmodel/core/benchmark.py @@ -239,7 +239,7 @@ def results(self, return ret - def statistics(self, metric="mae", vals=['mean', 'std', 'min', 'max', 'median'], sort=None): + def statistics(self, metric="mae", vals=['mean', 'std', 'min', 'max', 'median'], sort_by="mean", ascending=True): try: import pandas as pd except: @@ -249,8 +249,8 @@ def statistics(self, metric="mae", vals=['mean', 'std', 'min', 'max', 'median'], tbl = df.groupby(["label"]).agg({metric: vals}) df.groupby(["label"]).agg({metric: vals}) - if sort is not None: - tbl = tbl.sort_values((metric, vals[0]), ascending=sort) + if sort_by is not None: + tbl = tbl.sort_values((metric, sort_by), ascending=ascending) return tbl diff --git a/ezmodel/usage/models/usage_kriging.py b/ezmodel/usage/models/usage_kriging.py index 50d2356..a7c680d 100644 --- a/ezmodel/usage/models/usage_kriging.py +++ b/ezmodel/usage/models/usage_kriging.py @@ -2,14 +2,14 @@ import numpy as np from ezmodel.models.kriging import Kriging -from ezmodel.util.sample_from_func import sine_function +from ezmodel.util.sample_from_func import square_function model = Kriging(regr="linear", corr="gauss", ARD=False) # create some data to test this model on -X, y, _X, _y = sine_function(100, 20) +X, y, _X, _y = square_function(100, 20) # let the model fit the data model.fit(X, y) diff --git a/ezmodel/usage/scratch.py b/ezmodel/usage/scratch.py deleted file mode 100644 index ef15234..0000000 --- a/ezmodel/usage/scratch.py +++ /dev/null @@ -1,15 +0,0 @@ -from ezmodel.core.factory import ModelFactoryByClazz -from ezmodel.core.partitioning import merge_and_partition -from ezmodel.core.selection import ModelSelection -from ezmodel.models.kriging import Kriging -from ezmodel.util.sample_from_func import sine_function - -X, y, _X, _y = sine_function(100, 20) - - -models = ModelFactoryByClazz(Kriging).do() -X, y, partitions = merge_and_partition((X, y), (_X, _y)) - -model = ModelSelection(models, refit=False).do(X, y, partitions=partitions) - -print(model) diff --git a/setup.py b/setup.py index b571a43..55db5d2 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ description="Machine Learning, Model, Surrogate, Metamodels, Response Surface", license='Apache License 2.0', keywords="model", - install_requires=['numpy>=1.15', "pandas", "scipy", "sklearn", "pydacefit", "pySOT==0.2.3"], + install_requires=['numpy', "pandas", "scipy", "sklearn", "pydacefit", "matplotlib"], include_package_data=True, platforms='any', classifiers=[ diff --git a/tests/scratch.py b/tests/scratch.py new file mode 100644 index 0000000..757f595 --- /dev/null +++ b/tests/scratch.py @@ -0,0 +1,29 @@ +import numpy as np + +import pandas as pd +pd.set_option('display.expand_frame_repr', False) +pd.set_option('max_colwidth', 1000) + +from ezmodel.core.benchmark import Benchmark +from ezmodel.core.factory import models_from_clazzes +from ezmodel.models.kriging import Kriging +from ezmodel.models.rbf import RBF +from ezmodel.util.partitioning.crossvalidation import CrossvalidationPartitioning + +X = np.random.random((100, 3)) * 2 * np.pi +y = np.sin(X).sum(axis=1) + +models = models_from_clazzes(RBF, Kriging) + +# set up the benchmark and add the models to be used +benchmark = Benchmark(models, n_threads=4, verbose=True, raise_exception=True) + +# create partitions to validate the performance of each model +partitions = CrossvalidationPartitioning(k_folds=5, seed=1).do(X) + +# runs the experiment with the specified partitioning +benchmark.do(X, y, partitions=partitions) + +# print out the benchmark results +print(benchmark.statistics("mae")) +