question

MohsenSichani avatar image
0 Votes"
MohsenSichani asked MohsenSichani commented

DPHistogram Component returns True has type <class 'numpy.bool_'>, but expected one of: (<class 'bool'>, <class 'numbers.Integral'>)

Hi there,

I am running the below code from here but getting a strange error, how can I fix the issue

 ages = list(range(0, 130, 10))
 age = diabetes.Age
 with sn.Analysis() as analysis:
     data = sn.Dataset(path = data_path, column_names = cols)

     age_histogram = sn.dp_histogram(
         sn.cast(data['Age'], atomic_type='int', lower=0, upper=120),
         edges = ages,
         upper = 1000,
         null_value = -1,
         privacy_usage = {'epsilon': 0.5}
         )
        
 analysis.release()
 plt.ylim([0,100])
 width=4
 agecat_left = [x + width for x in ages]
 agecat_right = [x + 2*width for x in ages]
 plt.bar(list(range(0,120,10)), n_age, width=width, color='blue', alpha=0.7, label='True')
 plt.bar(agecat_left, age_histogram.value, width=width, color='orange', alpha=0.7, label='Private')
 plt.legend()
 plt.title('Histogram of Age')
 plt.xlabel('Age')
 plt.ylabel('Frequency')
 plt.show()

 print(age_histogram.value)



and the error


TypeError Traceback (most recent call last)
<ipython-input-67-ed764f55a5fe> in <module>
10 )
11
---> 12 analysis.release()

~\anaconda3\lib\site-packages\opendp\smartnoise\core\base.py in release(self)
799 response_proto: api_pb2.ResponseRelease.Success = core_library.compute_release(
800 serialize_analysis(self),
--> 801 serialize_release(self.release_values),
802 self.stack_traces,
803 serialize_filter_level(self.filter_level))

~\anaconda3\lib\site-packages\opendp\smartnoise\core\value.py in serialize_release(release_values)
103 def serialize_release(release_values):
104 return base_pb2.Release(
--> 105 values={
106 component_id: serialize_release_node(release_node)
107 for component_id, release_node in release_values.items()

~\anaconda3\lib\site-packages\opendp\smartnoise\core\value.py in <dictcomp>(.0)
104 return base_pb2.Release(
105 values={
--> 106 component_id: serialize_release_node(release_node)
107 for component_id, release_node in release_values.items()
108 if release_node['value'] is not None

~\anaconda3\lib\site-packages\opendp\smartnoise\core\value.py in serialize_release_node(release_node)
112 def serialize_release_node(release_node):
113 return base_pb2.ReleaseNode(
--> 114 value=serialize_value(
115 release_node['value'],
116 release_node.get("value_format")),

~\anaconda3\lib\site-packages\opendp\smartnoise\core\value.py in serialize_value(value, value_format)
210 array=value_pb2.Array(
211 shape=list(array.shape),
--> 212 flattened=serialize_array1d(array.flatten())
213 ))
214

~\anaconda3\lib\site-packages\opendp\smartnoise\core\value.py in serialize_array1d(array)
152
153 return value_pb2.Array1d(**{
--> 154 data_type: container_type(data=list(array))
155 })
156

~\anaconda3\lib\site-packages\google\protobuf\internal\python_message.py in init(self, **kwargs)
551 field_value = [_GetIntegerEnumValue(field.enum_type, val)
552 for val in field_value]
--> 553 copy.extend(field_value)
554 self._fields[field] = copy
555 elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:

~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in extend(self, elem_seq)
283 raise
284
--> 285 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
286 if new_values:
287 self._values.extend(new_values)

~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in <listcomp>(.0)
283 raise
284
--> 285 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
286 if new_values:
287 self._values.extend(new_values)

~\anaconda3\lib\site-packages\google\protobuf\internal\type_checkers.py in CheckValue(self, proposed_value)
135 message = ('%.1024r has type %s, but expected one of: %s' %
136 (proposed_value, type(proposed_value), self._acceptable_types))
--> 137 raise TypeError(message)
138 # Some field types(float, double and bool) accept other types, must
139 # convert to the correct type in such cases.

TypeError: True has type <class 'numpy.bool_'>, but expected one of: (<class 'bool'>, <class 'numbers.Integral'>)


azure-machine-learning
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thanks for reaching out. We are verifying this error with the product team, will keep you posted.

1 Vote 1 ·

Hi, Thanks, looking forward to hearing from you.

0 Votes 0 ·

Hi, sorry for the delayed response. I couldn't find relevant information regarding this error. My recommendation is to contact Azure Support, they may have more information to help diagnose this issue further. Sorry for any inconvenience.


0 Votes 0 ·

1 Answer

CarlosMauroOsorio-2398 avatar image
0 Votes"
CarlosMauroOsorio-2398 answered MohsenSichani commented

I'm having the same error when doing 13 - Explore Diferential privacy.ipynb from the exam DP-100. Is this issue solved yet? 🥺

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi

Nope, I think trying the code in the azure notepad rather than locally may solve the issue.

Haven't tried it, also still could not solve the issue locally

0 Votes 0 ·