Problems related to the image array operations (nan / inf)

New Year's more! I wish the new year technological strides Ha!

Recently fitted with a regression model to predict sklearn remote sensing images, encountered some problems, but fortunately all the solutions, now summarize.

1. First, the input data must sklearn the RESHAPE (-1,1) , only to be converted into this format input. For multi-factor data, to concatenate ((a, b), axis = 1), superimposed columns.

2.   a ValueError: the contains the Input NaN3, TOO Infinity Large value for A or DTYPE ( 'float64')
This means that the error data inputted there Nan / Inf, for nan, can be used False data == data or data [np.isnan (data)] = 0 negative;

Inf is the infinite, because the denominator is usually 0 to generate, using data [np.isinf (data)] = 0 to eliminate. The image operation that often this happens, pay attention to whether the denominator is 0 Oh!

3. The model data were standardized, so when the input image should be standardized.

4. Finally learned sklearn alternative method of nan.

imp = Imputer(missing_values=’NaN’, strategy=’mean’, axis=0, verbose=0, copy=True)

data = imp.fit_transform(data)

2020/1/1

Guess you like

Origin www.cnblogs.com/ljwgis/p/12131011.html