diff --git a/pylearning/ensembles/ensembles.py b/pylearning/ensembles/ensembles.py index b935e51..9726566 100644 --- a/pylearning/ensembles/ensembles.py +++ b/pylearning/ensembles/ensembles.py @@ -1,15 +1,16 @@ import logging -import random import abc import numpy as np from operator import itemgetter from concurrent.futures import ProcessPoolExecutor + from ..trees import DecisionTreeRegressor from ..trees import DecisionTreeClassifier +from six import add_metaclass - -class RandomForest(metaclass=abc.ABCMeta): +@add_metaclass(abc.ABCMeta) +class RandomForest(object): """ Abstract base class for random forest algorithms. This class is not meant to be instanciated, ont its subclasses can be used. diff --git a/pylearning/neighbours/neighbours.py b/pylearning/neighbours/neighbours.py index cc270d0..323b692 100644 --- a/pylearning/neighbours/neighbours.py +++ b/pylearning/neighbours/neighbours.py @@ -1,8 +1,9 @@ import abc import numpy as np +from six import add_metaclass - -class KNN(metaclass=abc.ABCMeta): +@add_metaclass(abc.ABCMeta) +class KNN(object): """ Abstract base class for nearest neighbours algorithms. This class is not meant to be instanciated, ont its subclasses can be used. diff --git a/pylearning/trees/trees.py b/pylearning/trees/trees.py index e0c1ad1..149127c 100644 --- a/pylearning/trees/trees.py +++ b/pylearning/trees/trees.py @@ -1,13 +1,14 @@ import random import abc import numpy as np -from math import log2, sqrt +#from math import log2, sqrt from numbers import Number from .node import DecisionNode +from six import add_metaclass - -class DecisionTree(metaclass=abc.ABCMeta): +@add_metaclass(abc.ABCMeta) +class DecisionTree(object): """ Abstract base class for decision trees. This class is not meant to be instanciated,only its subclasses can be used. @@ -68,9 +69,9 @@ def set_number_features_evaluated_split(self, row): self.max_split_features <= len(row) else len(row) elif isinstance(self.max_split_features, str): if self.max_split_features in ['auto','sqrt']: - self.considered_features = int(sqrt(len(row))) + self.considered_features = int(np.sqrt(len(row))) elif self.max_split_features == 'log2': - self.considered_features = int(log2(len(row))) + self.considered_features = int(np.log2(len(row))) else: self.considered_features = len(row) @@ -104,7 +105,7 @@ def entropy(self, targets): ent = 0.0 for val in results.values(): p = float(val) / len(targets) - ent -= p * log2(p) + ent -= p * np.log2(p) return ent diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a7bdf86 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[bdist_wheel] +universal = 1 + +[metadata] +license_file = LICENSE.md diff --git a/setup.py b/setup.py index 2955a41..cae5f6b 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ 'Intended Audience :: Developers', 'Topic :: Scientific/Engineering :: Artificial Intelligence', 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', @@ -37,5 +38,6 @@ packages=find_packages(exclude=['contrib','docs','tests']), - install_requires=['numpy'] + install_requires=['numpy','six','futures;python_version<"3"'] + )