<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ML-SPL sample command count=[subsearch value] issue in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/ML-SPL-sample-command-count-subsearch-value-issue/m-p/624245#M11742</link>
    <description>&lt;P&gt;I update my issue status in a separate post:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;| sample [susbsearch]&lt;/STRONG&gt; fails to be accelerated because both sample command (not a streaming command?) and subsearches aren't allowed in accelerated datasets.&lt;BR /&gt;&lt;BR /&gt;Nevertheless, according to data model docs:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;To accelerate a data model, it must contain at least one root event dataset, or one root search dataset that only uses streaming commands. Acceleration only affects these dataset types and datasets that are children of those root datasets. You cannot accelerate root search datasets that use nonstreaming commands (including transforming commands), root transaction datasets, and children of those datasets. &lt;STRONG&gt;Data models can contain a mixture of accelerated and unaccelerated datasets.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is strange that splunk fails to parse my search query. It should keep unaccerelable datasets unaccelerated. &lt;STRONG&gt;Why does this happen?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The other unresolved issue left is why this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sample count= [
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return $samples
      ]
      seed=29 by stroke&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raises this error in regular search queries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in 'sample' command: Invalid value for count: must be an int&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as i know, using&lt;STRONG&gt;&amp;nbsp;return $value&lt;/STRONG&gt; at the end of a subsearch that generates 1 value returns that value to the main search. Why isn't &lt;STRONG&gt;| sample count=[subsearch | return $value]&lt;/STRONG&gt; the same as &lt;STRONG&gt;| sample&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;count=&amp;lt;valuewrittenexplicitly&amp;gt;&lt;/STRONG&gt;?&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2022 13:25:27 GMT</pubDate>
    <dc:creator>isaiz</dc:creator>
    <dc:date>2022-12-16T13:25:27Z</dc:date>
    <item>
      <title>ML-SPL sample command count=[subsearch value] issue</title>
      <link>https://community.splunk.com/t5/Reporting/ML-SPL-sample-command-count-subsearch-value-issue/m-p/624164#M11741</link>
      <description>&lt;P&gt;Hi. I have an issue but I can't find the solution nor someone who had the same issue so I post it here.&lt;/P&gt;&lt;P&gt;I want to downsample the training part of a dataset using sample command. To do so, I get the count of the minority class using a subsearch and I use it to sample my dataset by class value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sample [
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return $samples
      ]
      seed=29 by stroke&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine, but when I use it inside an accelerated data model it raises the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in 'sample' command: Unrecognized argument: [ | search index=main sourcetype="heartstroke_csv" | sample partitions=10 seed=29 | where partition_number&amp;lt;8 and stroke=1 | stats count as samples | return count=samples ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I thought about explicitly assign the argument &lt;STRONG&gt;count&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sample count= [
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return $samples
      ]
      seed=29 by stroke&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this doesn't work even in a regular unaccelerated dataset. It returns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in 'sample' command: Invalid value for count: must be an int&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the V 8.2.5 of Splunk Enterprise and the V 5.3.3 of &lt;SPAN&gt;Splunk&amp;nbsp;&lt;/SPAN&gt;Machine Learning Toolkit. I don't know if it's a version issue or my syntax is wrong.&lt;/P&gt;&lt;P&gt;EDIT: I have tried also:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sample [
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return count=samples
      ] 
      seed=29 by stroke&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works only in the unaccelerated data model. In the accelerated fails to recognize the argument again.&lt;BR /&gt;&lt;BR /&gt;EDIT2: As the final trial, I put explicitly the integer values to the count parameter ( ... | sample count=193 ... ) It seems my&amp;nbsp; model is &lt;STRONG&gt;unaccelerable&lt;/STRONG&gt;. I have 2 datasets, one for the &lt;STRONG&gt;data&lt;/STRONG&gt; and the other for the ids that correspond to the regular and downsampled version of the train and test &lt;STRONG&gt;sets&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dataset: DATA

index=main sourcetype="heartstroke_csv"&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;dataset: SETS

index=main sourcetype="heartstroke_csv"
| sample partitions=10 seed=29
| eval set=if(partition_number&amp;lt;8,"train","test")
| appendpipe [
  | where set="train" 
  | appendpipe [
      | where stroke=0 and bmi!="N/A" or stroke=1
      | sample count=193 ```[
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return count=samples
      ] ```
      seed=29 by stroke
      | stats values(id) as ids by set | eval downsample=1
      ]
  | appendpipe [
      | stats values(id) as ids by set | eval downsample=0
      ]
  | search ids=*
  ]
| appendpipe [
  | where set="test" 
  | appendpipe [
      | sample count=56 ```[
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;gt;=8 and stroke=1 
         | stats count as samples
         | return count=samples
         ]```   
      seed=29 by stroke
      | stats values(id) as ids by set | eval downsample=1
      ]
  | appendpipe [
      | stats values(id) as ids by set | eval downsample=0
      ]
  | search ids=*
  ]
| search ids=*
| rename ids as id
| table id set downsample&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 10:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/ML-SPL-sample-command-count-subsearch-value-issue/m-p/624164#M11741</guid>
      <dc:creator>isaiz</dc:creator>
      <dc:date>2022-12-14T10:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: ML-SPL sample command count=[subsearch value] issue</title>
      <link>https://community.splunk.com/t5/Reporting/ML-SPL-sample-command-count-subsearch-value-issue/m-p/624245#M11742</link>
      <description>&lt;P&gt;I update my issue status in a separate post:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;| sample [susbsearch]&lt;/STRONG&gt; fails to be accelerated because both sample command (not a streaming command?) and subsearches aren't allowed in accelerated datasets.&lt;BR /&gt;&lt;BR /&gt;Nevertheless, according to data model docs:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;To accelerate a data model, it must contain at least one root event dataset, or one root search dataset that only uses streaming commands. Acceleration only affects these dataset types and datasets that are children of those root datasets. You cannot accelerate root search datasets that use nonstreaming commands (including transforming commands), root transaction datasets, and children of those datasets. &lt;STRONG&gt;Data models can contain a mixture of accelerated and unaccelerated datasets.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is strange that splunk fails to parse my search query. It should keep unaccerelable datasets unaccelerated. &lt;STRONG&gt;Why does this happen?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The other unresolved issue left is why this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sample count= [
         | search index=main sourcetype="heartstroke_csv" 
         | sample partitions=10 seed=29 
         | where partition_number&amp;lt;8 and stroke=1 
         | stats count as samples
         | return $samples
      ]
      seed=29 by stroke&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raises this error in regular search queries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in 'sample' command: Invalid value for count: must be an int&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as i know, using&lt;STRONG&gt;&amp;nbsp;return $value&lt;/STRONG&gt; at the end of a subsearch that generates 1 value returns that value to the main search. Why isn't &lt;STRONG&gt;| sample count=[subsearch | return $value]&lt;/STRONG&gt; the same as &lt;STRONG&gt;| sample&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;count=&amp;lt;valuewrittenexplicitly&amp;gt;&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 13:25:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/ML-SPL-sample-command-count-subsearch-value-issue/m-p/624245#M11742</guid>
      <dc:creator>isaiz</dc:creator>
      <dc:date>2022-12-16T13:25:27Z</dc:date>
    </item>
  </channel>
</rss>

