From: Sinacam Date: Sun, 7 Aug 2022 14:01:37 +0000 (+0800) Subject: added comment on resize X-Git-Tag: v245~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b341aec710c2e8ba789a5184e7289f4b199c493;p=liblinear added comment on resize --- diff --git a/python/README b/python/README index aa31a00..2f376e6 100644 --- a/python/README +++ b/python/README @@ -136,6 +136,7 @@ If numba (http://numba.pydata.org) is installed, some operations will be much fa There are two levels of usage. The high-level one uses utility functions in liblinearutil.py and the usage is the same as the LIBLINEAR MATLAB interface. +>>> import numpy as np >>> import scipy >>> from liblinear.liblinearutil import * # Read data in LIBSVM format @@ -145,7 +146,6 @@ in liblinearutil.py and the usage is the same as the LIBLINEAR MATLAB interface. # Construct problem in Scipy format # Dense data: numpy ndarray ->>> import numpy as np >>> y, x = np.asarray([1,-1]), np.asarray([[1,0,1], [-1,0,-1]]) # Sparse data: scipy csr_matrix((data, (row_ind, col_ind)) >>> y, x = np.asarray([1,-1]), scipy.sparse.csr_matrix(([1, 1, -1, -1], ([0, 0, 1, 1], [0, 2, 0, 2]))) diff --git a/python/liblinear/commonutil.py b/python/liblinear/commonutil.py index 91e0151..c3aca93 100644 --- a/python/liblinear/commonutil.py +++ b/python/liblinear/commonutil.py @@ -160,7 +160,7 @@ def csr_scale(x, scale_param): if not n == len(coef): print("WARNING: The dimension of scaling parameters and feature number do not match.", file=sys.stderr) - coef = coef.resize(n) + coef = coef.resize(n) # zeros padded if n > len(coef) offset = offset.resize(n) # scaled_x = x * diag(coef) + ones(l, 1) * offset'