# How to extract input data just knowing the output values?

**URL:** https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380
**Category:** General Usage
**Tags:** question
**Created:** [April 1, 2021, 5:08pm UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380 "2021-04-01T17:08:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mdsa3d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mdsa3d/32/20389_2.png) [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)
#### Post date: [April 1, 2021, 5:08pm UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380/1 "2021-04-01T17:08:26Z")

</div>

I would like to inquire, how may i extract input data from a given dataset (I guess it is similar to data decomposition).  
The goal is to decompose a dataset to extract the features?

**For example:** Extract individual components of the `volume` of `rectangle prism` (without the knowledge of the `individual features` like length, width, height).

Please do recommend best practice to carry out such operation.  
Also, do suggest any learning material (book or article) which can lead me in right direction.

The example code for the analysis:

```julia
using DataFrames
mutable struct rect
    length
    breadth
    height
end
r = rect(rand(Int, 40), rand(Int, 40), rand(Int, 40))
volume(rect) = rect.length .* rect.breadth .* rect.height
volume_val = volume(r)
df = DataFrame(:length => r.length, :width=> r.width, :height=> r.height, :volume => volume_val)

# For this df dataframe, I would like to extract length, width and height from volume without the use of volume equation

```

Thanks in advance!

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [April 1, 2021, 6:34pm UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380/2 "2021-04-01T18:34:26Z")

</div>

I’m not sure I understand the question - you have a single number (volume) which is the product of three other numbers (length, breadth, width) and you want to figure out which numbers were multiplied together to create the single number? This sounds to me like you’re trying to solve one equation with three unknowns?

---

<div class="post-metadata">

### Author: ![mdsa3d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mdsa3d/32/20389_2.png) [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)
#### Post date: [April 2, 2021, 1:26am UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380/3 "2021-04-02T01:26:26Z")

</div>

Thanks for the response, Yes, indeed this is what I am trying to do!  
Is there any approach you have in mind which can be applied to such operation ? (given I have an array of `volume`).

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [April 2, 2021, 2:16am UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380/4 "2021-04-02T02:16:41Z")

</div>

Perhaps it is easier to think about a simpler case. Consider two rectangles, 1 \times 4 and 2 \times 2. Both have area 4, and there are others too. Since there is more than one combination of side-lengths that can produce area 4, what answer would you like to get?

---

<div class="post-metadata">

### Author: ![Dave.Shone](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dave.Shone](https://discourse.julialang.org/u/Dave.Shone)
#### Post date: [April 2, 2021, 3:27am UTC](https://discourse.julialang.org/t/how-to-extract-input-data-just-knowing-the-output-values/58380/5 "2021-04-02T03:27:04Z")

</div>

I’m guessing that perhaps you want to query the data frame using a particular output value (volume in this case) or range of output values in order to obtain the corresponding input data.

DataFrames provides the filter function, for example:

`filter(:volume => >(500), df)`

Will give rows of df where :volume\>500 and similarly

`filter(:volume => ==(500), df)`

gives rows where :volume==500.

See the [DataFrames tutorial](https://github.com/bkamins/Julia-DataFrames-Tutorial/blob/master/06_rows.ipynb) for more details.

In addition, [@where in DataFramesMeta](https://juliadata.github.io/DataFramesMeta.jl/stable/#@where) provides similar functionality and [Query](http://www.queryverse.org/Query.jl/stable/) provides many more options.
