0

I using jupyter notebook and graphlab / turi for tfidf-nearest_neighbors model, which works fine so far.

However, when I query the model like

tfidf_model.query(Test_AD) I always just get the head - [5 rows x 4 columns]

I am supposed to use "print_rows(num_rows=m, num_columns=n)" to print more rows and columns like:

tfidf_model.query(Test_AD).print_rows(num_rows=50, num_columns=4)

however, when I used it, I dont get any rows anymore, only the summary field:

Starting pairwise querying. +--------------+---------+-------------+--------------+ | Query points | # Pairs | % Complete. | Elapsed Time | +--------------+---------+-------------+--------------+ | 0 | 1 | 0.00519481 | 13.033ms | | Done | | 100 | 106.281ms | +--------------+---------+-------------+--------------+

That's it. No error message, nothing. Any Ideas, how to get all/ more rows?

I tried to convert into pandas or .show() command etc., didnt help.

Bass Dee
  • 91
  • 1
  • 3

3 Answers3

0

ok, well, seems like I have to define the number or neighbours with:

tfidf_model.query(Test_AD, k=100).show()

so I can get a list of first 100 in the canvass.

Bass Dee
  • 91
  • 1
  • 3
0

This situation happens due to inability of Jupyter Notebook to show every line in a same frame. There are several ways to print and see your requirements.

  1. Select range using SFrame. For Example: -

    sf[100:] # Returns an SFrame containing rows 100 to the end
    sf[:100] # Returns an SFrame containing rows 0 to row 99 inclusive
    sf[0:100:2] # Returns an SFrame containing rows 0 to row 100 in steps of 2
    sf[-100:] # Returns an SFrame containing last 100 rows
    sf[-100:len(sf):2] # Returns an SFrame containing last 100 rows in steps of 2
    
  2. You may also convert SFrame to data frame, slice the data and printing. Ex.

    df = pd.DataFrame({i: range(1000) for i in range(100)})
    df.ix[:5, :10]  
    
  3. You may also play with head and tail:-

    df.head(n)
    df.tail(n)
    
  4. You can output the data and save in some file like .csv/ .xls file and see your results. Ex.

    SFrame.export_csv(filename, delimiter=', ', line_terminator='\n', header=True, quote_level=2, double_quote=True, escape_char='\\', quote_char='"', na_rep='', file_header='', file_footer='', line_prefix='', _no_prefix_on_first_value=False, **kwargs)
    

Please refer to the documentation on SFrame. I hope that helps.

Hari_pb
  • 7,088
  • 3
  • 45
  • 53
0

print_rows is intended method on a Sframe or a model. Here is example for a model:

model1.get("coefficients").print_rows(num_rows=16, num_columns=6)
zhrist
  • 1,169
  • 11
  • 28