]> granicus.if.org Git - liblinear/commitdiff
added comment on resize
authorSinacam <stinkingmadgod@gmail.com>
Sun, 7 Aug 2022 14:01:37 +0000 (22:01 +0800)
committerSinacam <stinkingmadgod@gmail.com>
Sun, 7 Aug 2022 14:01:37 +0000 (22:01 +0800)
python/README
python/liblinear/commonutil.py

index aa31a00a4af595c9bc0023fcc0a037cf3d5b6940..2f376e646b98aa318ffb83880919506f6f2406b0 100644 (file)
@@ -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])))
index 91e015119e1f872a567a9996b1005c75e6d7ec94..c3aca9371f6c9c89cff1910ed4317d91d4af935d 100644 (file)
@@ -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'