argmax of List of Double
So you want the index of the maximum value in your collection. That's a lot of code for such a simple task.
Let's start at the top.
q_table_test.txt - The sample data supplied is rather ridiculous. The elements that will become &quot;attribute values&quot; are all the same. How do you know the code is correct if there is no maximum? Does it matter which index is returned?
QTable.apply(filename) - The number_attributes_per_instance should be a configuration parameter, or derived directly from the input data. What if you needed to support more than one number_attributes_per_instance?
You don't appear to know what a lazy val is and what it's for. Its usage here makes no sense.
There are no safety checks. The file text is loaded as if formatting errors can't happen.
getQTableFromFile() - Why is getResourceAsStream() wrapped in an Option and then unwrapped with a .get? That's like loaning your brother a dollar so that he can repay the dollar he borrowed from you yesterday. A lot of busy work that accomplishes nothing.
cleanData() - Very inefficient.
getArgMaxValue() - If the state parameter is faulty you go through the trouble of building a bogus qValues list and then the elaborate and convoluted steps of finding the index of its max value, of which there is none. If you're going to lie to the user why not just return remainingPositions.head and be done with it?

As a demonstration, here's a smaller yet safer implementation of the same basic outline.
import scala.util.{Try, Using}  //Scala 2.13.x

class QTable(bindings: Map[String, Array[Double]]) {
  def getMaxValueIdx(state              : String
                    ,remainingPositions : List[Int]
                    ) :Option[Int] =
    bindings.get(state)
            .flatMap(arr =&gt; remainingPositions.maxByOption(arr.lift))
}

object QTable {
  private def loadFromFile(filename :String) :Try[String] =
    Using(scala.io.Source.fromFile(filename)) {
      _.getLines().map(_.takeWhile(_ != '#').trim).mkString
    }

  private val recFormat =
    &quot;&quot;&quot;([^,&quot;\[\]]+)\s*,((\s*('\d*\.?\d*')\s*,?)+)&quot;&quot;&quot;.r.unanchored

  def apply(filename :String) :QTable =
    loadFromFile(filename).flatMap{ data =&gt; Try {
      recFormat.findAllMatchIn(data)
        .map(m =&gt; m.group(1) -&gt; m.group(2)
                                 .split(&quot;[,\\s]+&quot;)
                                 .collect{case s&quot;'$n'&quot; =&gt; n.toDouble}
            ).toMap
    }}.fold(err =&gt; {println(err); new QTable(Map.empty)}
           ,new QTable(_))
}

My q_table_test.txt file:
[
&quot;1st 9 Tbl,'0','1','2','3','4','5','6','7','8', #table of 9 elements
&quot;Short Tbl,   '7' , '1.1','.22', '3'  ,'12.0' , #mixed spacing
&quot;Split Tbl, '17', '1.25', '.127', '300.003'     #1st part
          , '12.0', '4321', '.1234'           , #2nd part
&quot;2nd 9 Tbl,'0.','0.9','0.8','0.7','0.6','0.5','0.4','0.3','0.2'&quot;
]

testing:
val qx = QTable(&quot;bogus.txt&quot;)    // (No such file or directory)
qx.getMaxValueIdx(&quot;1st 9 Tbl&quot;, List(7, 2, 3))  // None

val qt = QTable(&quot;./q_table_test.txt&quot;)
qt.getMaxValueIdx(&quot;1st 9 Tbl&quot;, List(7, 2, 3))  // Some(7)
qt.getMaxValueIdx(&quot;1st 9 Tbl&quot;, List())         // None
qt.getMaxValueIdx(&quot;Short Tbl&quot;, List(2,3,0))    // Some(0)
qt.getMaxValueIdx(&quot;Short Tbl&quot;, List(2,3,990))  // Some(3)
qt.getMaxValueIdx(&quot;NoSuchTbl&quot;, List(5,0,8))    // None
qt.getMaxValueIdx(&quot;Split Tbl&quot;, List(5,0,8))    // Some(5)
qt.getMaxValueIdx(&quot;2nd 9 Tbl&quot;, List(7, 2, 3))  // Some(2)