I'm working on my Neural Network project, and in data set I have only string values, but I know that NN accepts only numerical values so how can I convert string to double like this :
“red” = 0.4582932
“green” = 0.512932
“black” = 0.542123
I'm working on my Neural Network project, and in data set I have only string values, but I know that NN accepts only numerical values so how can I convert string to double like this :
“red” = 0.4582932
“green” = 0.512932
“black” = 0.542123
If the values are dynamic then use the solution that @ElliotFrisch provided in the question comments regarding the use of a Map of type String and Double respectively.
If the values are predetermined and do not change then an enumeration might be the solution for you.
enum Color {
RED(0.4582932),
GREEN(0.512932),
BLACK(0.542123);
private final double value;
private Color(double value) {
this.value = value;
}
}
You could then create a Set of the enum values. ImmutableSet here.
private static final Set<Color> COLORS = ImmutableSet.copyOf(EnumSet.allOf(Color.class));