1

I've been studying Machine Learning lately and now I'm working on Factorization Machines (Rendle's first papyer, 2010).

I've found later on https://github.com/srendle/libfm so I can apply that for specific train / test data.

The matrix (i.e training data) has to be in .txt format. What I've done so far working on a csv data file on Python in order to build the feature vectors X (intoduced here http://www.algo.uni-konstanz.de/members/rendle/pdf/Rendle2010FM.pdf) which gives me the matrix ... in Python.

Is it possible to extract it in .txt format or anything like that?

martineau
  • 119,623
  • 25
  • 170
  • 301
mlx
  • 504
  • 1
  • 4
  • 15
  • Define ".txt format". txt files contain no headers or special blocks or compressed sections or anything -- it's all just ordinary bytes. You could rename your `data.csv` file to `data.txt` and it would technically be a valid .txt file. – Kevin Jun 02 '17 at 12:27

1 Answers1

1

You can use numpy.savetxt

import numpy
m = numpy.array([[1,2],[3,4]])
f = open('f.txt', 'w')
numpy.savetxt(f, m, fmt='%s')
f.close()

edit f.txt:

1 2
3 4
Nuageux
  • 1,668
  • 1
  • 17
  • 29