#NEWLINE# def output_transformation( self ) : #NEWLINE# #INDENT# '\n        Build sigmoid output transformation:\n        proba = 1 / (1 + exp(-(initial_estimate + weighted_sum(estimates))))\n        :return: Output element\n        ' #NEWLINE# output = pmml . Output ( ) #NEWLINE# for f in self . context . schemas [ Schema . INTERNAL ] : #NEWLINE# #INDENT# output . append ( pmml . OutputField ( feature = 'predictedValue' , name = Schema . INTERNAL . extract_feature_name ( f ) ) ) #NEWLINE# #UNINDENT# positive_category = self . context . schemas [ Schema . CATEGORIES ] [ 1 ] #NEWLINE# output_field = pmml . OutputField ( dataType = positive_category . data_type . value , feature = 'transformedValue' , name = Schema . CATEGORIES . extract_feature_name ( positive_category ) , optype = positive_category . optype . value ) #NEWLINE# neg = pmml . Apply ( function = '*' ) #NEWLINE# neg . append ( pmml . FieldRef ( field = Schema . INTERNAL . extract_feature_name ( positive_category . namespace ) ) ) #NEWLINE# neg . append ( pmml . Constant ( ( - ( 1 + ( self . estimator . n_estimators * self . estimator . learning_rate ) ) ) , dataType = FeatureType . DOUBLE . value ) ) #NEWLINE# exp = pmml . Apply ( function = 'exp' ) #NEWLINE# exp . append ( neg ) #NEWLINE# plus = pmml . Apply ( function = '+' ) #NEWLINE# plus . append ( pmml . Constant ( 1.0 , dataType = FeatureType . DOUBLE . value ) ) #NEWLINE# plus . append ( exp ) #NEWLINE# div = pmml . Apply ( function = '/' ) #NEWLINE# div . append ( pmml . Constant ( 1.0 , dataType = FeatureType . DOUBLE . value ) ) #NEWLINE# div . append ( plus ) #NEWLINE# output_field . append ( div ) #NEWLINE# output . append ( output_field ) #NEWLINE# negative_category = self . context . schemas [ Schema . CATEGORIES ] [ 0 ] #NEWLINE# output_field = pmml . OutputField ( dataType = negative_category . data_type . value , feature = 'transformedValue' , name = Schema . CATEGORIES . extract_feature_name ( negative_category ) , optype = negative_category . optype . value ) #NEWLINE# subtract = pmml . Apply ( function = '-' ) #NEWLINE# subtract . append ( pmml . Constant ( 1 , dataType = FeatureType . DOUBLE . value ) ) #NEWLINE# subtract . append ( pmml . FieldRef ( field = Schema . CATEGORIES . extract_feature_name ( positive_category ) ) ) #NEWLINE# output_field . append ( subtract ) #NEWLINE# output . append ( output_field ) #NEWLINE# label = self . context . schemas [ Schema . OUTPUT ] [ 0 ] #NEWLINE# output_field = pmml . OutputField ( feature = 'transformedValue' , name = Schema . OUTPUT . extract_feature_name ( label ) , optype = label . optype . value , dataType = label . data_type . value ) #NEWLINE# discretize = pmml . Discretize ( field = Schema . INTERNAL . extract_feature_name ( label ) ) #NEWLINE# discretize_bin = pmml . DiscretizeBin ( binValue = label . value_list [ 0 ] ) #NEWLINE# discretize_bin . append ( pmml . Interval ( closure = 'openOpen' , rightMargin = 0 ) ) #NEWLINE# discretize . append ( discretize_bin ) #NEWLINE# discretize_bin = pmml . DiscretizeBin ( binValue = label . value_list [ 1 ] ) #NEWLINE# discretize_bin . append ( pmml . Interval ( closure = 'closedOpen' , leftMargin = 0 ) ) #NEWLINE# discretize . append ( discretize_bin ) #NEWLINE# output_field . append ( discretize ) #NEWLINE# output . append ( output_field ) #NEWLINE# return output