Does the np.nan in numpy array occupy memory?

前端 未结 3 1385
忘了有多久
忘了有多久 2021-01-21 00:57

I have a huge file of csv which can not be loaded into memory. Transforming it to libsvm format may save some memory. There are many nan in csv file. If I read lines and store

3条回答
  •  醉话见心
    2021-01-21 01:40

    As far as I know yes, nan and zero values occupy the same memory as any other value, however, you can address your problem in other ways:

    Have you tried using a sparse vector? they are intended for vectors with a lot of 0 values and memory consumption is optimized

    SVM Module Scipy

    Sparse matrices Scipy

    There you have some info about SVM and sparse matrices, if you have further questions just ask.

    Edited to provide an answer as well as a solution

提交回复
热议问题