Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.1K Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Build a (x,y) -> (X,Y) mapping for a machine learning application?

Posted 6 years ago

Hello Everyone,

I would like to build a 2 dimensionnal mapping from numeric pairs of data (x,y) measurements to extract a pair of measured values X,Y. Physically I use a pair of independant sensors x and y which value depends on two physical parameters X and Y. I want to evaluate the X,Y value based on the sensor output (x,y). I tried an analytic approach but I am curious to check what a neural net or other machine learning method can produce... Unfortunately I am such noob in Mathematica Machine Learning features that the most intuitive syntax did not work and I am lost in the huge documentation stack. A little help to solve this problem would be appreciated. I put the input data with desired output in the following set:

In[338]:= dataset

Out[338]= {{68.6309, 129.667} -> {2.5, 3.1}, {70.2941, 
   99.9095} -> {2., 5.2}, {113.909, 321.53} -> {6., 2.8}, {142.928, 
   232.101} -> {4.5, 5.1}, {55.3224, 238.227} -> {5.5, 1.5}, {119.522,
    208.819} -> {4., 4.4}, {150.741, 261.237} -> {5., 4.7}, {41.072, 
   111.443} -> {4., 0.8}, {84.092, 236.134} -> {4.5, 2.5}, {48.7884, 
   135.185} -> {3., 1.5}, {43.5032, 160.155} -> {5., 1.}, {74.889, 
   129.237} -> {2.5, 3.7}, {50.9653, 99.9456} -> {2., 2.1}, {68.9513, 
   100.215} -> {2., 4.8}, {123.316, 322.451} -> {6., 3.}, {119.153, 
   176.668} -> {3.5, 5.7}, {107.202, 294.082} -> {5.5, 2.8}, {64.871, 
   220.448} -> {4.5, 1.9}, {38.7254, 50.6979} -> {5., 0.2}, {189.644, 
   310.274} -> {6., 5.3}, {38.6468, 48.4711} -> {2.5, 0.1}, {57.1366, 
   225.476} -> {5., 1.6}, {61.1515, 102.059} -> {2., 3.3}, {85.6425, 
   125.906} -> {2.5, 5.3}, {104.585, 150.047} -> {3., 6.}, {38.7243, 
   50.7576} -> {5.5, 0.2}, {42.4376, 166.234} -> {6., 0.9}, {182.675, 
   280.109} -> {5.5, 5.8}, {61.4204, 215.622} -> {4.5, 1.8}, {85.9459,
    156.648} -> {3., 3.7}, {153.129, 259.867} -> {5., 4.8}, {157.689, 
   290.152} -> {5.5, 4.4}, {40.3509, 72.9105} -> {2., 0.8}, {138.715, 
   323.33} -> {6., 3.4}, {135.675, 234.858} -> {4.5, 4.6}, {38.9446, 
   58.2436} -> {2.5, 0.4}, {170.61, 285.175} -> {5.5, 5.}, {41.1801, 
   146.194} -> {6., 0.8}, {50.4667, 189.199} -> {4.5, 1.4}, {155.337, 
   290.8} -> {5.5, 4.3}, {85.4773, 125.797} -> {2.5, 5.2}, {65.5635, 
   154.854} -> {3., 2.4}, {160.191, 257.469} -> {5., 5.3}, {50.2766, 
   156.212} -> {3.5, 1.5}, {184.011, 311.758} -> {6., 5.}, {97.224, 
   184.132} -> {3.5, 3.7}, {132.302, 235.906} -> {4.5, 4.4}, {93.617, 
   239.2} -> {4.5, 2.8}, {180.038, 281.284} -> {5.5, 5.6}, {84.092, 
   236.134} -> {4.5, 2.5}, {41.2955, 89.0044} -> {2.5, 0.9}, {162.174,
    256.902} -> {5., 5.4}, {41.65, 112.208} -> {3.5, 0.9}, {42.3083, 
   108.205} -> {3., 1.}, {90.6357, 155.272} -> {3., 4.1}, {111.265, 
   239.624} -> {4.5, 3.4}, {60.6884, 233.118} -> {5., 1.7}, {39.8793, 
   95.6126} -> {5., 0.6}, {50.4796, 233.256} -> {6., 1.3}, {43.4821, 
   114.843} -> {3., 1.1}, {119.153, 176.668} -> {3.5, 5.7}, {142.948, 
   263.592} -> {5., 4.3}, {185.97, 311.757} -> {6., 5.1}, {40.2314, 
   98.7904} -> {4., 0.7}, {102.905, 150.98} -> {3., 5.6}, {82.4606, 
   127.227} -> {2.5, 4.7}, {60.2038, 102.346} -> {2., 3.2}, {141.6, 
   232.627} -> {4.5, 5.}, {132.302, 235.906} -> {4.5, 4.4}, {139.056, 
   294.435} -> {5.5, 3.7}, {57.1366, 225.476} -> {5., 1.6}, {39.9041, 
   68.7561} -> {2., 0.7}, {39.7357, 91.0486} -> {4.5, 0.6}, {189.644, 
   310.274} -> {6., 5.3}, {76.1032, 128.777} -> {2.5, 3.8}, {126.486, 
   266.681} -> {5., 3.6}, {39.7658, 100.218} -> {5.5, 0.6}, {58.6326, 
   246.947} -> {5.5, 1.6}, {40.8331, 102.376} -> {3.5, 0.8}, {67.3071,
    202.198} -> {4., 2.1}, {38.8807, 54.7734} -> {3.5, 0.3}, {92.7047,
    155.039} -> {3., 4.3}, {46.183, 94.5789} -> {2., 1.6}, {107.202, 
   294.082} -> {5.5, 2.8}, {38.7246, 50.5458} -> {4., 0.2}, {53.5837, 
   101.482} -> {2., 2.4}, {51.6686, 208.37} -> {5., 1.4}, {148.376, 
   292.113} -> {5.5, 4.}, {119.153, 176.668} -> {3.5, 5.7}, {151.33, 
   228.195} -> {4.5, 5.8}, {182.737, 312.524} -> {6., 4.9}, {65.9409, 
   262.386} -> {5.5, 1.8}, {135.675, 234.858} -> {4.5, 4.6}, {38.8756,
    56.6874} -> {5.5, 0.3}, {49.0207, 98.1754} -> {2., 1.9}, {97.9427,
    152.873} -> {3., 4.9}, {41.4433, 80.3218} -> {2., 1.}, {46.0737, 
   111.286} -> {2.5, 1.4}, {130.595, 204.734} -> {4., 5.3}, {43.4189, 
   88.6406} -> {2., 1.3}}

For instance, in the training dataset member {68.6309, 129.667} -> {2.5, 3.1}, {68.6309, 129.667} is the (x,y) input and {2.5, 3.1} is the desired (X,Y) output.

Then when I apply Predict to this dataset I get the following error:

In[339]:= p = Predict[dataset]

During evaluation of In[339]:= Predict::mlincfttp: Incompatible variable type (Numerical) and variable value ({2.5,3.1}).

Can someone explain how I can get a pair of number when I enter a pair of numbers?

Thanks in advance

Christian

POSTED BY: Christian Neel
5 Replies

I tried and got some results but far away from the solution and the convergence seems to reach a steady level with no progress. I guess I have to dig in the NetChain documentation for the right net structure. Thanks anyway.

Christian

POSTED BY: Christian Neel
Posted 6 years ago

Yes, my example is pretty rough. Further step you can have a tried may be: build a network that has two parallel network subcomponents which accept the same input vector, but output two individual outputs which correspond to the first and the second value of your output, then combined them together as the final output.

POSTED BY: Jason Zhao

Thanks! That is exactly what I did. In that case I could use the Predict function and try various implementation functions (NeuralNet, ClosestNeighbor, etc) and variable subset as learning data. In most cases I get pretty well decoupled outputs that are easy to use.I just now have to see whats's under the hood to implemenet it on a separate microcontroller...

Christian

POSTED BY: Christian Neel
Posted 6 years ago

A brief thought: you can build a simple neural network that has an output length of 2. For example:

mlp = NetChain[{LinearLayer[6], ElementwiseLayer[Ramp], 
   LinearLayer[2]}, "Input" -> 2]
mlp = NetInitialize[mlp]
result = NetTrain[mlp, dataset]

This simplest net takes input of length 2 and output an vector with length of 2 as well. You can feed your (x,y) to the trained net. Just like result[{x,y}].

POSTED BY: Jason Zhao

I'll try thanks!

POSTED BY: Christian Neel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard