Message Boards Message Boards

0
|
2765 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Missing values in the output of SynthesizeMissingValues?

Posted 2 years ago

Hi,

For my dataset with missing data points, I used SynthesizeMissingValues command in Mathematica. Unfortunately, I didn't get a suitable answer. Where is my mistake?

Any help would be greatly appreciated

data = {{9.6`, 0.`, 36.`, 18.1`}, {9.7`, 0.`, 34.3`, 
   17.4`}, {10.4`, 0.`, 33.1`, 15.9`}, {12.5`, 0.`, 36.7`, 
   18.5`}, {12.2`, 0.`, 41.7`, 23.2`}, {9.1`, 0.`, 36.3`, 
   21.8`}, {7.6`, 0.`, 32.7`, 16.3`}, {" ", 0.`, " ", 17.5`}, {" ", 
   " ", " ", " "}, {" ", " ", 28.6`, " "}, {5.2`, 0.4`, 27.7`, 
   14.8`}, {" ", 0.2`, " ", 9.9`}, {" ", " ", 26.1`, " "}, {" ", " ", 
   " ", 13.1`}, {" ", " ", 39.4`, " "}, {9.2`, 0.`, 39.`, 
   24.3`}, {6.7`, 0.`, 33.1`, 19.4`}, {6.5`, 0.`, 29.9`, 14.`}, {7.`, 
   0.`, 30.5`, 15.8`}, {9.1`, 0.`, 36.6`, 14.6`}, {6.1`, 0.`, 29.4`, 
   16.2`}, {7.5`, 0.`, 30.`, 14.4`}, {7.7`, 0.`, 30.5`, 15.5`}}

SynthesizeMissingValues[data, 
 Method -> "KernelDensityEstimation"]

 {{9.6, 0., 36., 18.1}, {9.7, 0., 34.3, 17.4}, {10.4, 0., 33.1,
   15.9}, {12.5, 0., 36.7, 18.5}, {12.2, 0., 41.7, 23.2}, {9.1, 0., 
  36.3, 21.8}, {7.6, 0., 32.7, 16.3}, {" ", 0., " ", 17.5}, {" ", " ",
   " ", " "}, {" ", " ", 28.6, " "}, {5.2, 0.4, 27.7, 14.8}, {" ", 
  0.2, " ", 9.9}, {" ", " ", 26.1, " "}, {" ", " ", " ", 13.1}, {" ", 
  " ", 39.4, " "}, {9.2, 0., 39., 24.3}, {6.7, 0., 33.1, 19.4}, {6.5, 
  0., 29.9, 14.}, {7., 0., 30.5, 15.8}, {9.1, 0., 36.6, 14.6}, {6.1, 
  0., 29.4, 16.2}, {7.5, 0., 30., 14.4}, {7.7, 0., 30.5, 15.5}}
POSTED BY: Alex Teymouri
4 Replies
Posted 2 years ago

Hi Alex,

Check the documentation for MissingValuePattern.

SynthesizeMissingValues[data,
 MissingValuePattern -> " ",
 Method -> "KernelDensityEstimation"]

Or

SynthesizeMissingValues[data /. " " -> Missing[], 
 Method -> "KernelDensityEstimation"]
POSTED BY: Rohit Namjoshi
Posted 2 years ago

Thank you so much, Rohit.

I evaluated the method for my main data. I attached herewith the data. Unfortunately, I received an error again.I know this is my mistake.

enter image description here

Attachments:
POSTED BY: Alex Teymouri
Posted 2 years ago

Hi Alex,

Always good to understand the nature of the data you are dealing with and make sure it is what you expect.

data = Import["~/Downloads/data.xlsx"] // First;

data // Flatten // Map[Head] // Counts
(* <|Real -> 34730, String -> 326|> *)

data // Flatten // Cases[_String] // DeleteDuplicates
(* {" ", ""} *)

There are empty strings and strings with one space. The MissingValuePattern has to be more generic.

(* Any String is considered as missing *)
SynthesizeMissingValues[data,
 MissingValuePattern -> _String,
 Method -> "KernelDensityEstimation"]
POSTED BY: Rohit Namjoshi
Posted 2 years ago

I really appreciate your time, Rohit.

Your solution ways always are incredible.

Thank you.

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

Group Abstract Group Abstract