Question: I have a dataset which is around 10k and I am splitting the data into a 80:20 ratio in sklearn's train\_test\_split module...However I fail to understand the reason behind the outputs not matching the original dataset when they are added. for eg here's the size of my dataset created using df.shape `(9538, 15)`. Now if I put this into train\_test\_split I get something like

```
from sklearn.model_selection import train_test_split
train, test =  train_test_split(df_fake,test_size=0.2, random_state=0)
train, val =  train_test_split(df_fake,test_size=0.25,random_state=0)
print('Train-',train.shape)
print('Val-',val.shape)
print('Test-',test.shape)

```

the outputs:- 

```
Train- (7153, 15)
Val- (2385, 15)
Test- (1908, 15)

```

So if I add the testset with the validation set it comes to - 4293 and when this figure is added to the train set it comes to 11446. whereas I have got the data of only 9.5K.. Is it something that I am doing wrong?

Answer: 
The documentation of [`local_variables`](https://ruby-doc.org/core-2.7.1/Kernel.html#method-i-local_variables) tells that it only returns an array with the names of the local variables. 

But you could use that method to generate the hash:

```
local_variables.map { |name| [name, eval(name.to_s)] }.to_h

```

I think that is a bit error-prone because you might return unexpected variables and their values.

Perhaps it would be better to refector your method to something like this:

```
LIBRARIES = { 
  libjq: 'jquery',
  liblf: 'leaflet',
  libbs: 'twitter-bootstrap',
  libfa: 'font-awesome'
}

def library_urls
  LIBRARIES.map { |k, v| 
    [k, JSON.parse(URI.open("https://api.cdnjs.com/libraries/#{v}").read)['latest']] 
  }.to_h  
end

```
Well, the problem is that you are assigning the result hash to a local variable, so if you want to return a list of local variables, then of course that variable will be included.

The two simplest solutions I can think of would be:

Filter out the name of that local variable.

Just don't assign it. I.e. where you have `r = something`, just return `something` without assigning it to `r` in the first place. Something like this:

```rb
def get_map_libs
  libjq = :jq
  liblf = :lf
  libbs = :bs
  libfa = :fa

  local_variables.map {|var| [var, binding.local_variable_get(var)] }.to_h
end

get_map_libs
#=> { :libjq => :jq, :liblf => :lf, :libbs => :bs, :libfa => :fa }

```