1
$\begingroup$

From Google Dive: SequencePredictorFunction is here, along with my test data.

From pastbin: prediction function and data is here.

Using the .mx

sq = Import["seq_go.mx"];
res = Import["listall.MX"];

Now get ready to test the predictions: (I think this is what needs performance tunning??)

myCompare[list_] := Module[
   {nlist, predict, result},
   nlist = Length[list];
   predict = 
    Prepend[sq /@ Table[Take[list, n], {n, 1, nlist - 1}], "NA"];
   result = MapThread[Equal, {predict, list}];
   result[[1]] = Count[result, True]/nlist // N;
   result
   ];
myCompare[res[[1]]]

{0.4375, False, False, False, False, False, True, False, False, True, False, False, True, False, False, False, True, False, False, True, True, False, True, False, True, False, True, True, True, False, True, True, True, True, True, True, False, False, True, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, True, False, True, True, False, True, True, False, False, True, False, True, False, False, False, True, True, True, False, True, False, True, True, False, False}

This is only for one run. If I then do

(myCompare /@ res;) // AbsoluteTiming

{2.299, Null}

Suppose if the Length[res] is 200,000. It would take a long time. I am wondering if there is any way to improve efficiency here (and keep each True/False)?

Thanks.

$\endgroup$
  • 2
    $\begingroup$ I'm not able to import the .mx files because of version problem. If the function is not big, try pasting it here. Also, for the test data you may want to use pastebin. $\endgroup$ – Anjan Kumar Nov 27 '17 at 3:46
  • $\begingroup$ ... or export it as package (.m)... $\endgroup$ – Henrik Schumacher Nov 27 '17 at 9:03
  • $\begingroup$ @AnjanKumar @Henrik Due to the "large" data I used to generate the SequencePredictorFunction, I don't think (.m) actually saves anything apart from the raw code. I feel that the main problem would be the in myCompare, which might need performance tunning? $\endgroup$ – Chen Stats Yu Nov 27 '17 at 9:25
  • $\begingroup$ @AnjanKumar I have updated the pastebin links. Please let me know if that works. Thanks. $\endgroup$ – Chen Stats Yu Nov 27 '17 at 9:37
  • $\begingroup$ Okay, I tried the code. Right at the beginning myCompare makes a call sq[{"B"}]. This does not get evaluated for sq is merely an association wrapped by SequencePredictorFunction. I would at least expect either some DownValues assigned to sq or some UpValues assigned to SequencePredictorFunction in order to make it working. Maybe, you also want to export the definitions of SequencePredictorFunction? $\endgroup$ – Henrik Schumacher Nov 27 '17 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.