Why pickle.dump(obj) has different size with sys.getsizeof(obj)? How to save variable to file file?
问题 I use classifier of random forest from scikit lib of python to do my exercise. The result changes each running time. So I run 1000 times and get the average result. I save object rf into files to predict later by pickle.dump() and get about 4MB each file. However, sys.getsizeof(rf) give me just 36 bytes rf = RandomForestClassifier(n_estimators = 50) rf.fit(matX, vecY) pickle.dump(rf,'var.sav') My questions: sys.getsizeof() seems to be wrong in getting size of RandomForestClassifier object,