Skip to content

Commit

Permalink
REF: Use distutils for version check
Browse files Browse the repository at this point in the history
  • Loading branch information
jseabold committed Nov 27, 2015
1 parent 202a53d commit 3f0539b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions mrec/item_similarity/slim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
http://glaros.dtc.umn.edu/gkhome/fetch/papers/SLIM2011icdm.pdf
"""
from __future__ import print_function, absolute_import
from distutils.version import LooseVersion
from six.moves import xrange
from sklearn.linear_model import SGDRegressor, ElasticNet
from sklearn.preprocessing import binarize
Expand All @@ -20,12 +21,6 @@
from mrec.item_similarity.recommender import ItemSimilarityRecommender


def parse_version(version_string):
if '-' in version_string:
version_string = version_string.split('-', 1)[0]
return tuple(map(int, version_string.split('.')))


class NNFeatureSelectingSGDRegressor(object):
"""
Wraps nearest-neighbour feature selection and regression in a single model.
Expand Down Expand Up @@ -78,7 +73,7 @@ def __init__(self,
model='sgd'):
alpha = l1_reg+l2_reg
l1_ratio = l1_reg/alpha
if parse_version(sklearn.__version__) <= (0, 14, 1):
if LooseVersion(sklearn.__version__) <= LooseVersion('0.14.1'):
# Backward compat: in old versions of scikit-learn l1_ratio had
# the opposite sign...
l1_ratio = (1 - l1_ratio)
Expand Down

0 comments on commit 3f0539b

Please sign in to comment.