OpenNN  2.2
Open Neural Networks Library
missing_values.cpp
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* M I S S I N G V A L U E S C L A S S */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
11 /* */
12 /****************************************************************************************************************/
13 
14 // OpenNN includes
15 
16 #include "missing_values.h"
17 
18 namespace OpenNN
19 {
20 
21 // DEFAULT CONSTRUCTOR
22 
26 
28 {
29  set();
30 
31  set_default();
32 }
33 
34 
35 // INSTANCES AND VARIABLES NUMBER CONSTRUCTOR
36 
40 
41 MissingValues::MissingValues(const size_t& new_instances_number,const size_t& new_variables_number)
42 {
43  set(new_instances_number, new_variables_number);
44 
45  set_default();
46 }
47 
48 
49 // XML CONSTRUCTOR
50 
54 
55 MissingValues::MissingValues(const tinyxml2::XMLDocument& missing_values_document)
56 {
57  set(missing_values_document);
58 }
59 
60 
61 // COPY CONSTRUCTOR
62 
66 
67 MissingValues::MissingValues(const MissingValues& other_missing_values)
68 {
69  instances_number = other_missing_values.instances_number;
70  variables_number = other_missing_values.variables_number;
71 
72  scrubbing_method = other_missing_values.scrubbing_method;
73 
74  items = other_missing_values.items;
75 
76  display = other_missing_values.display;
77 }
78 
79 
80 // DESTRUCTOR
81 
83 
85 {
86 }
87 
88 
89 // ASSIGNMENT OPERATOR
90 
94 
96 {
97  if(this != &other_missing_values)
98  {
99  instances_number = other_missing_values.instances_number;
100  variables_number = other_missing_values.variables_number;
101 
102  items = other_missing_values.items;
103 
104  display = other_missing_values.display;
105  }
106 
107  return(*this);
108 }
109 
110 
111 // EQUAL TO OPERATOR
112 
113 // bool operator == (const MissingValues&) const method
114 
119 
120 bool MissingValues::operator == (const MissingValues& other_missing_values) const
121 {
122  if(items == other_missing_values.items
123  && display == other_missing_values.display)
124  {
125  return(true);
126  }
127  else
128  {
129  return(false);
130  }
131 }
132 
133 
134 // METHODS
135 
136 // size_t get_instances_number(void) const method
137 
139 
141 {
142  return(instances_number);
143 }
144 
145 
146 // size_t get_variables_number(void) const method
147 
149 
151 {
152  return(variables_number);
153 }
154 
155 
156 // Vector<size_t> get_missing_values_numbers(void) const method
157 
160 
162 {
163  Vector<size_t> missing_values_numbers(variables_number, 0);
164 
165  const size_t missing_values_number = get_missing_values_number();
166 
167  size_t variable_index;
168 
169  for(size_t i = 0; i < missing_values_number; i++)
170  {
171  variable_index = items[i].variable_index;
172 
173  missing_values_numbers[variable_index]++;
174  }
175 
176  return(missing_values_numbers);
177 }
178 
179 
180 // const Vector<Item>& get_items(void) const method
181 
183 
185 {
186  return(items);
187 }
188 
189 
190 // const Item& get_item(const size_t&) const method
191 
194 
195 const MissingValues::Item& MissingValues::get_item(const size_t& index) const
196 {
197  // Control sentence (if debug)
198 
199 #ifndef NDEBUG
200 
201  const size_t missing_values_number = get_missing_values_number();
202 
203  if(index >= missing_values_number)
204  {
205  std::ostringstream buffer;
206 
207  buffer << "OpenNN Exception: MissingValues class.\n"
208  << "const Item& get_item(const size_t&) const method.\n"
209  << "Index (" << index << ") must be less than number of missing values (" << missing_values_number << ").\n";
210 
211  throw std::logic_error(buffer.str());
212  }
213 
214 #endif
215 
216  return(items[index]);
217 }
218 
219 
220 // ScrubbingMethod get_scrubbing_method(void) const
221 
223 
225 {
226  return(scrubbing_method);
227 }
228 
229 
230 // std::string write_scrubbing_method(void) const method
231 
233 
235 {
236  if(scrubbing_method == Unuse)
237  {
238  return("Unuse");
239  }
240  else if(scrubbing_method == Mean)
241  {
242  return("Mean");
243  }
244  if(scrubbing_method == NoScrubbing)
245  {
246  return("NoScrubbing");
247  }
248  else
249  {
250  std::ostringstream buffer;
251 
252  buffer << "OpenNN Exception: MissingValues class.\n"
253  << "std::string write_scrubbing_method(void) const method.\n"
254  << "Unknown scrubbing method.\n";
255 
256  throw std::logic_error(buffer.str());
257  }
258 }
259 
260 
261 // std::string write_scrubbing_method_text(void) const method
262 
264 
266 {
267  if(scrubbing_method == Unuse)
268  {
269  return("unuse");
270  }
271  else if(scrubbing_method == Mean)
272  {
273  return("mean");
274  }
275  else if(scrubbing_method == NoScrubbing)
276  {
277  return("no scrubbing");
278  }
279  else
280  {
281  std::ostringstream buffer;
282 
283  buffer << "OpenNN Exception: MissingValues class.\n"
284  << "std::string write_scrubbing_method_text(void) const method.\n"
285  << "Unknown scrubbing method.\n";
286 
287  throw std::logic_error(buffer.str());
288  }
289 }
290 
291 
292 // const bool& get_display(void) const method
293 
296 
297 const bool& MissingValues::get_display(void) const
298 {
299  return(display);
300 }
301 
302 
303 // void set(void) method
304 
306 
308 {
309  instances_number = 0;
310  variables_number = 0;
311 
313 
314  set_default();
315 }
316 
317 
318 // void set(const size_t&, const size_t&) method
319 
323 
324 void MissingValues::set(const size_t& new_instances_number, const size_t& new_variables_number)
325 {
326  instances_number = new_instances_number;
327  variables_number = new_variables_number;
328 
330 
331  set_default();
332 }
333 
334 
335 // void set(const tinyxml2::XMLDocument&) method
336 
339 
340 void MissingValues::set(const tinyxml2::XMLDocument& document)
341 {
342  set();
343 
344  from_XML(document);
345 }
346 
347 
348 // void set_instances_number(const size_t&) method
349 
351 
352 void MissingValues::set_instances_number(const size_t& new_instances_number)
353 {
355 
356  instances_number = new_instances_number;
357 }
358 
359 
360 // void set_variables_number(const size_t&) method
361 
363 
364 void MissingValues::set_variables_number(const size_t& new_variables_number)
365 {
367 
368  variables_number = new_variables_number;
369 }
370 
371 
372 // void set_default(void) method
373 
379 
381 {
382  scrubbing_method = Unuse;
383 
384  display = true;
385 }
386 
387 
388 // void set_display(const bool&) method
389 
394 
395 void MissingValues::set_display(const bool& new_display)
396 {
397  display = new_display;
398 }
399 
400 
401 // void set_items(const Vector<Item>&) method
402 
404 
406 {
407  items = new_items;
408 }
409 
410 
411 // void set_item(const size_t&, const size_t&, const size_t&) method
412 
414 
415 void MissingValues::set_item(const size_t& index, const size_t& instance_index, const size_t& variable_index)
416 {
417  // Control sentence (if debug)
418 
419 #ifndef NDEBUG
420 
421  const size_t missing_values_number = get_missing_values_number();
422 
423  if(index >= missing_values_number)
424  {
425  std::ostringstream buffer;
426 
427  buffer << "OpenNN Exception: MissingValues class.\n"
428  << "void set_item(const size_t&, const size_t&, const size_t&) method.\n"
429  << "Index (" << index << ") must be less than number of missing values (" << missing_values_number << ").\n";
430 
431  throw std::logic_error(buffer.str());
432  }
433 
434  if(instance_index >= instances_number)
435  {
436  std::ostringstream buffer;
437 
438  buffer << "OpenNN Exception: MissingValues class.\n"
439  << "void set_item(const size_t&, const size_t&, const size_t&) method.\n"
440  << "Index of instance (" << instance_index << ") must be less than number of instances (" << instances_number << ").\n";
441 
442  throw std::logic_error(buffer.str());
443  }
444 
445  if(variable_index >= variables_number)
446  {
447  std::ostringstream buffer;
448 
449  buffer << "OpenNN Exception: MissingValues class.\n"
450  << "void set_item(const size_t&, const size_t&, const size_t&) method.\n"
451  << "Index of variable (" << variable_index << ") must be less than number of variables (" << variables_number << ").\n";
452 
453  throw std::logic_error(buffer.str());
454  }
455 
456 #endif
457 
458  items[index].instance_index = instance_index;
459  items[index].variable_index = variable_index;
460 }
461 
462 
463 // void append(const size_t&, const size_t&) method
464 
468 
469 void MissingValues::append(const size_t& instance_index, const size_t& variable_index)
470 {
471 #ifndef NDEBUG
472 
473  if(instance_index >= instances_number)
474  {
475  std::ostringstream buffer;
476 
477  buffer << "OpenNN Exception: MissingValues class.\n"
478  << "void append(const size_t&, const size_t&) method.\n"
479  << "Index of instance (" << instance_index << ") must be less than number of instances (" << instances_number << ").\n";
480 
481  throw std::logic_error(buffer.str());
482  }
483 
484  if(variable_index >= variables_number)
485  {
486  std::ostringstream buffer;
487 
488  buffer << "OpenNN Exception: MissingValues class.\n"
489  << "void append(const size_t&, const size_t&) method.\n"
490  << "Index of variable (" << variable_index << ") must be less than number of instances (" << variables_number << ").\n";
491 
492  throw std::logic_error(buffer.str());
493  }
494 
495 #endif
496 
497  Item item(instance_index, variable_index);
498 
499  items.push_back(item);
500 }
501 
502 
503 // void set_missing_values_number(const size_t&) method
504 
507 
508 void MissingValues::set_missing_values_number(const size_t& new_missing_values_number)
509 {
510  items.set(new_missing_values_number);
511 }
512 
513 
514 // void set_scrubbing_method(const ScrubbingMethod&) method
515 
518 
519 void MissingValues::set_scrubbing_method(const ScrubbingMethod& new_scrubbing_method)
520 {
521  scrubbing_method = new_scrubbing_method;
522 }
523 
524 
525 // void set_scrubbing_method(const std::string&) method
526 
529 
530 void MissingValues::set_scrubbing_method(const std::string& new_scrubbing_method)
531 {
532  if(new_scrubbing_method == "Unuse")
533  {
534  scrubbing_method = Unuse;
535  }
536  else if(new_scrubbing_method == "Mean")
537  {
538  scrubbing_method = Mean;
539  }
540  else
541  {
542  std::ostringstream buffer;
543 
544  buffer << "OpenNN Exception: MissingValues class.\n"
545  << "void new_scrubbing_method(const std::string&) method.\n"
546  << "Unknown scrubbing method: " << new_scrubbing_method << ".\n";
547 
548  throw std::logic_error(buffer.str());
549  }
550 }
551 
552 // bool has_missing_values(void) const method
553 
556 
558 {
559  if(items.empty())
560  {
561  return(false);
562  }
563  else
564  {
565  return(true);
566  }
567 }
568 
569 
570 // bool has_missing_values(const size_t&) const method
571 
575 
576 bool MissingValues::has_missing_values(const size_t& instance_index) const
577 {
578  if(items.empty())
579  {
580  return(false);
581  }
582 
583  const size_t missing_values_number = get_missing_values_number();
584 
585  for(size_t i = 0; i < missing_values_number; i++)
586  {
587  if(items[i].instance_index == instance_index)
588  {
589  return(true);
590  }
591  }
592 
593  return(false);
594 }
595 
596 
597 // bool has_missing_values(const size_t&, const Vector<size_t>&) const method
598 
603 
604 bool MissingValues::has_missing_values(const size_t& instance_index, const Vector<size_t>& variables_indices) const
605 {
606  const size_t missing_values_number = get_missing_values_number();
607 
608  const size_t variables_number = variables_indices.size();
609 
610  for(size_t i = 0; i < missing_values_number; i++)
611  {
612  if(items[i].instance_index == instance_index)
613  {
614  for(size_t j = 0; j < variables_number; j++)
615  {
616  if(items[i].variable_index == variables_indices[j])
617  {
618  return(true);
619  }
620  }
621  }
622  }
623 
624  return(false);
625 }
626 
627 
628 // bool is_missing_value(const size_t&, const size_t&) const method
629 
633 
634 bool MissingValues::is_missing_value(const size_t& instance_index, const size_t& variable_index) const
635 {
636  if(items.empty())
637  {
638  return(false);
639  }
640 
641  const size_t missing_values_number = get_missing_values_number();
642 
643  for(size_t i = 0; i < missing_values_number; i++)
644  {
645  if(items[i].instance_index == instance_index && items[i].variable_index == variable_index)
646  {
647  return(true);
648  }
649  }
650 
651  return(false);
652 }
653 
654 
655 // Vector<size_t> arrange_missing_instances(void) const method
656 
658 
660 {
661  const size_t missing_values_number = get_missing_values_number();
662 
663  Vector<size_t> missing_instances;
664 
665  for(size_t i = 0; i < missing_values_number; i++)
666  {
667  if(!missing_instances.contains(items[i].instance_index))
668  {
669  missing_instances.push_back(items[i].instance_index);
670  }
671  }
672 
673  return(missing_instances);
674 }
675 
676 
677 // size_t count_missing_instances(void) const method
678 
680 
682 {
683  return(arrange_missing_instances().size());
684 }
685 
686 
687 // Vector<size_t> arrange_missing_variables(void) const method
688 
690 
692 {
693  const size_t missing_values_number = get_missing_values_number();
694 
695  Vector<size_t> missing_variables;
696 
697  for(size_t i = 0; i < missing_values_number; i++)
698  {
699  if(!missing_variables.contains(items[i].variable_index))
700  {
701  missing_variables.push_back(items[i].variable_index);
702  }
703  }
704 
705  return(missing_variables);
706 }
707 
708 
709 // void convert_time_series(const size_t&) method
710 
712 
713 void MissingValues::convert_time_series(const size_t& lags_number)
714 {
715  if(lags_number == 0)
716  {
717  return;
718  }
719 /*
720  const size_t missing_values_number = get_missing_values_number();
721 
722  // const size_t new_missing_values_number = missing_values_number*(1+lags_number);
723 
724  Vector<Item> new_items;
725 
726 // size_t instance_index;
727 // size_t variable_index;
728 
729  Item new_item;
730 
731  for(size_t i = 0; i < missing_values_number; i++)
732  {
733  instance_index = items[i].instance_index;
734  variable_index = items[i].variable_index;
735 
736  for(size_t j = 0; j < 1+lags_number; j++)
737  {
738  new_item.instance_index = items[i].instance_index+j;
739 
740  new_item.variable_index = items[i].variable_index*(1+j);
741 
742  new_items.push_back(new_item);
743  }
744  }
745 
746  set_items(new_items);
747 */
748 }
749 
750 
751 // void convert_autoassociation(void) method
752 
754 
756 {
757  const size_t missing_values_number = get_missing_values_number();
758 
759  Vector<Item> autoassociation_items(missing_values_number);
760 
761 }
762 
763 
764 // Vector< Vector<size_t> > arrange_missing_indices(void) const method
765 
769 
771 {
772  Vector< Vector<size_t> > missing_indices(variables_number);
773 
774  const size_t missing_values_number = get_missing_values_number();
775 
776  size_t variable_index;
777  size_t instance_index;
778 
779  for(size_t i = 0; i < missing_values_number; i++)
780  {
781  variable_index = items[i].variable_index;
782  instance_index = items[i].instance_index;
783 
784  missing_indices[variable_index].push_back(instance_index);
785  }
786 
787  return(missing_indices);
788 }
789 
790 
791 // tinyxml2::XMLDocument* to_XML(void) const method
792 
796 
797 tinyxml2::XMLDocument* MissingValues::to_XML(void) const
798 {
799  tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument;
800 
801  std::ostringstream buffer;
802 
803  // MissingValues
804 
805  tinyxml2::XMLElement* missing_values_element = document->NewElement("MissingValues");
806 
807  document->InsertFirstChild(missing_values_element);
808 
809  tinyxml2::XMLElement* element = NULL;
810  tinyxml2::XMLText* text = NULL;
811 
812  const size_t missing_values_number = get_missing_values_number();
813 
814  // Instances number
815  {
816  element = document->NewElement("InstancesNumber");
817  missing_values_element->LinkEndChild(element);
818 
819  buffer.str("");
820  buffer << instances_number;
821 
822  text = document->NewText(buffer.str().c_str());
823  element->LinkEndChild(text);
824  }
825 
826  // Variables number
827  {
828  element = document->NewElement("VariablesNumber");
829  missing_values_element->LinkEndChild(element);
830 
831  buffer.str("");
832  buffer << variables_number;
833 
834  text = document->NewText(buffer.str().c_str());
835  element->LinkEndChild(text);
836  }
837 
838  // Scrubbing method
839  {
840  element = document->NewElement("ScrubbingMethod");
841  missing_values_element->LinkEndChild(element);
842 
843  text = document->NewText(write_scrubbing_method().c_str());
844  element->LinkEndChild(text);
845  }
846 
847  // Missing values number
848  {
849  element = document->NewElement("MissingValuesNumber");
850  missing_values_element->LinkEndChild(element);
851 
852  buffer.str("");
853  buffer << missing_values_number;
854 
855  text = document->NewText(buffer.str().c_str());
856  element->LinkEndChild(text);
857  }
858 
859  for(size_t i = 0; i < missing_values_number; i++)
860  {
861  element = document->NewElement("Item");
862  element->SetAttribute("Index", (unsigned)i+1);
863  missing_values_element->LinkEndChild(element);
864 
865  // Instance index
866 
867  tinyxml2::XMLElement* instance_index_element = document->NewElement("InstanceIndex");
868  element->LinkEndChild(instance_index_element);
869 
870  buffer.str("");
871  buffer << items[i].instance_index;
872 
873  text = document->NewText(buffer.str().c_str());
874  instance_index_element->LinkEndChild(text);
875 
876  // Variable index
877 
878  tinyxml2::XMLElement* variable_index_element = document->NewElement("VariableIndex");
879  element->LinkEndChild(variable_index_element);
880 
881  buffer.str("");
882  buffer << items[i].variable_index;
883 
884  text = document->NewText(buffer.str().c_str());
885  variable_index_element->LinkEndChild(text);
886  }
887 
888  // Display
889  {
890  element = document->NewElement("Display");
891  missing_values_element->LinkEndChild(element);
892 
893  buffer.str("");
894  buffer << display;
895 
896  text = document->NewText(buffer.str().c_str());
897  element->LinkEndChild(text);
898  }
899 
900  return(document);
901 }
902 
903 
904 // void from_XML(const tinyxml2::XMLDocument&) method
905 
909 
910 void MissingValues::from_XML(const tinyxml2::XMLDocument& document)
911 {
912  std::ostringstream buffer;
913 
914  // Missing values element
915 
916  const tinyxml2::XMLElement* missing_values_element = document.FirstChildElement("MissingValues");
917 
918  if(!missing_values_element)
919  {
920  buffer << "OpenNN Exception: MissingValues class.\n"
921  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
922  << "Pointer to MissingValues element is NULL.\n";
923 
924  throw std::logic_error(buffer.str());
925  }
926 
927  // Instances number
928 
929  const tinyxml2::XMLElement* instances_number_element = missing_values_element->FirstChildElement("InstancesNumber");
930 
931  if(!instances_number_element)
932  {
933  buffer << "OpenNN Exception: MissingValues class.\n"
934  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
935  << "Pointer to instances number is NULL.\n";
936 
937  throw std::logic_error(buffer.str());
938  }
939 
940  instances_number = atoi(instances_number_element->GetText());
941 
942  // Variables number
943 
944  const tinyxml2::XMLElement* variables_number_element = missing_values_element->FirstChildElement("VariablesNumber");
945 
946  if(!variables_number_element)
947  {
948  buffer << "OpenNN Exception: MissingValues class.\n"
949  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
950  << "Pointer to variables number is NULL.\n";
951 
952  throw std::logic_error(buffer.str());
953  }
954 
955  variables_number = atoi(variables_number_element->GetText());
956 
957  // Scrubbing method
958 
959  const tinyxml2::XMLElement* scrubbing_method_element = missing_values_element->FirstChildElement("ScrubbingMethod");
960 
961  if(!scrubbing_method_element)
962  {
963  buffer << "OpenNN Exception: MissingValues class.\n"
964  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
965  << "Pointer to scrubbing method element is NULL.\n";
966 
967  throw std::logic_error(buffer.str());
968  }
969 
970  const std::string scrubbing_method_string = scrubbing_method_element->GetText();
971 
972  set_scrubbing_method(scrubbing_method_string);
973 
974  // Missing values number
975 
976  const tinyxml2::XMLElement* missing_values_number_element = missing_values_element->FirstChildElement("MissingValuesNumber");
977 
978  if(!missing_values_number_element)
979  {
980  buffer << "OpenNN Exception: MissingValues class.\n"
981  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
982  << "Pointer to missing values number is NULL.\n";
983 
984  throw std::logic_error(buffer.str());
985  }
986 
987  const size_t missing_values_number = atoi(missing_values_number_element->GetText());
988 
989  set_missing_values_number(missing_values_number);
990 
991  if(missing_values_number <= 0)
992  {
993  return;
994  }
995 
996  // Items
997 
998  unsigned index = 0;
999 
1000  const tinyxml2::XMLElement* start_element = missing_values_number_element;
1001 
1002  for(size_t i = 0; i < missing_values_number; i++)
1003  {
1004  const tinyxml2::XMLElement* item_element = start_element->NextSiblingElement("Item");
1005  start_element = item_element;
1006 
1007  if(!item_element)
1008  {
1009  buffer << "OpenNN Exception: MissingValues class.\n"
1010  << "void from_XML(const tinyxml2::XMLElement*) method.\n"
1011  << "Item " << i+1 << " is NULL.\n";
1012 
1013  throw std::logic_error(buffer.str());
1014  }
1015 
1016  item_element->QueryUnsignedAttribute("Index", &index);
1017 
1018  if(index != i+1)
1019  {
1020  buffer << "OpenNN Exception: MissingValues class.\n"
1021  << "void from_XML(const tinyxml2::XMLElement*) method.\n"
1022  << "Index " << index << " is not correct.\n";
1023 
1024  throw std::logic_error(buffer.str());
1025  }
1026 
1027  // Instance index
1028 
1029  const tinyxml2::XMLElement* instance_index_element = item_element->FirstChildElement("InstanceIndex");
1030 
1031  if(!instance_index_element)
1032  {
1033  buffer << "OpenNN Exception: MissingValues class.\n"
1034  << "void from_XML(const tinyxml2::XMLElement*) method.\n"
1035  << "Pointer to instance index element is NULL.\n";
1036 
1037  throw std::logic_error(buffer.str());
1038  }
1039 
1040  const size_t instance_index = atoi(instance_index_element->GetText());
1041 
1042  items[i].instance_index = instance_index;
1043 
1044  // Variable index
1045 
1046  const tinyxml2::XMLElement* variable_index_element = item_element->FirstChildElement("VariableIndex");
1047 
1048  if(!instance_index_element)
1049  {
1050  buffer << "OpenNN Exception: MissingValues class.\n"
1051  << "void from_XML(const tinyxml2::XMLElement*) method.\n"
1052  << "Pointer to variable index element is NULL.\n";
1053 
1054  throw std::logic_error(buffer.str());
1055  }
1056 
1057  const size_t variable_index = atoi(variable_index_element->GetText());
1058 
1059  items[i].variable_index = variable_index;
1060  }
1061 }
1062 
1063 
1064 // std::string to_string(void) const method
1065 
1067 
1068 std::string MissingValues::to_string(void) const
1069 {
1070  std::ostringstream buffer;
1071 
1072  const size_t missing_values_number = get_missing_values_number();
1073 
1074  buffer << "Missing values object\n"
1075  << "Instances number: " << instances_number << "\n"
1076  << "Variables number: " << variables_number << "\n"
1077  << "Missing values number: " << missing_values_number << "\n";
1078 
1079  for(size_t i = 0; i < missing_values_number; i++)
1080  {
1081  buffer << "Missing value " << i+1 << ":\n"
1082  << "Instance index: " << items[i].instance_index << "\n"
1083  << "Variable index: " << items[i].variable_index << "\n";
1084  }
1085 
1086  buffer << "Scrubbing method: " << write_scrubbing_method() << "\n";
1087 
1088  buffer << "Display: " << display << "\n";
1089 
1090  return(buffer.str());
1091 }
1092 
1093 
1094 // void print(void) const method
1095 
1097 
1098 void MissingValues::print(void) const
1099 {
1100  std::cout << to_string();
1101 }
1102 
1103 
1104 
1105 }
1106 
1107 
1108 // OpenNN: Open Neural Networks Library.
1109 // Copyright (c) 2005-2015 Roberto Lopez.
1110 //
1111 // This library is free software; you can redistribute it and/or
1112 // modify it under the terms of the GNU Lesser General Public
1113 // License as published by the Free Software Foundation; either
1114 // version 2.1 of the License, or any later version.
1115 //
1116 // This library is distributed in the hope that it will be useful,
1117 // but WITHOUT ANY WARRANTY; without even the implied warranty of
1118 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1119 // Lesser General Public License for more details.
1120 
1121 // You should have received a copy of the GNU Lesser General Public
1122 // License along with this library; if not, write to the Free Software
1123 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
std::string write_scrubbing_method_text(void) const
Returns a string with the name of the method used for scrubbing, as paragaph text.
void convert_time_series(const size_t &)
ScrubbingMethod get_scrubbing_method(void) const
Returns the method to be used for dealing with the missing values.
bool display
Display messages to screen.
MissingValues & operator=(const MissingValues &)
ScrubbingMethod
Enumeration of available activation functions for the perceptron neuron model.
void set_instances_number(const size_t &)
Sets the number of data set instances in this object.
void set_item(const size_t &, const size_t &, const size_t &)
Sets the indices.
Vector< size_t > arrange_missing_instances(void) const
Returns a vector with the indices of those instances with missing values.
bool operator==(const MissingValues &) const
const Vector< Item > & get_items(void) const
Returns a constant reference to the vector of missing value items.
void convert_autoassociation(void)
bool has_missing_values(void) const
size_t variables_number
Number of variables.
tinyxml2::XMLDocument * to_XML(void) const
Vector< size_t > get_missing_values_numbers(void) const
bool contains(const T &) const
Returns true if the vector contains a certain value, and false otherwise.
Definition: vector.h:950
Vector< Item > items
Missing values.
void print(void) const
Prints to the screen information about the missing values object.
Vector< size_t > arrange_missing_variables(void) const
Returns a vector with the indices of those variables with missing values.
void set_display(const bool &)
void append(const size_t &, const size_t &)
void set_items(const Vector< Item > &)
Sets a new vector of missing value items.
const Item & get_item(const size_t &) const
const bool & get_display(void) const
void set_missing_values_number(const size_t &)
void set(void)
Sets a missing values object with zero instances, variables and missing values.
bool is_missing_value(const size_t &, const size_t &) const
ScrubbingMethod scrubbing_method
Method for handling missing values.
std::string to_string(void) const
Returns a string representation of the current MissingValues object.
size_t get_instances_number(void) const
Returns the number of instances in the data set.
void set_variables_number(const size_t &)
Sets the number of data set variables in this object.
void from_XML(const tinyxml2::XMLDocument &)
virtual ~MissingValues(void)
Destructor.
size_t count_missing_instances(void) const
Returns the number of instances with missing values.
size_t get_variables_number(void) const
Returns the number of variables in the data set.
std::string write_scrubbing_method(void) const
Returns a string with the name of the method used for scrubbing.
size_t instances_number
Number of instances.
void set_scrubbing_method(const ScrubbingMethod &)
size_t get_missing_values_number(void) const
Returns the number of missing values in the data set.
Vector< Vector< size_t > > arrange_missing_indices(void) const