Setting valuation attributes alone is not enough - at least in the general case for all valuations.
I know at least one example where this can fail.
LinearDiscriminantAnalysis.transform()
uses a private attribute _max_components
:
def transform(self, X):
return X_new[:, :self._max_components]
. , , __init__()
.fit()
.
, .__dict__
. :.
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
lda = LDA().fit([[1, 2, 3], [1, 2, 1], [4, 5, 6], [9, 9, 9]], [1, 2, 1, 2])
lda.__dict__
# {'_max_components': 1,
# 'classes_': array([1, 2]),
# 'coef_': array([[ -9.55555556, 21.55555556, -9.55555556]]),
# 'explained_variance_ratio_': array([ 1.]),
# 'intercept_': array([-15.77777778]),
# 'means_': array([[ 2.5, 3.5, 4.5],
# [ 5. , 5.5, 5. ]]),
# 'n_components': None,
# 'priors': None,
# 'priors_': array([ 0.5, 0.5]),
# 'scalings_': array([[-2.51423299],
# [ 5.67164186],
# [-2.51423299]]),
# 'shrinkage': None,
# 'solver': 'svd',
# 'store_covariance': False,
# 'tol': 0.0001,
# 'xbar_': array([ 3.75, 4.5 , 4.75])}
, , , . . Scikit-learn Persistence JSON Serialization.
, scikit-learn. - , , , .