# Copyright (c) 2016. Mount Sinai School of Medicine # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import numpy def from_ic50(ic50): """ Convert ic50s to regression targets in the range [0.0, 1.0]. Parameters ---------- ic50 : numpy.array of float Returns ------- numpy.array of float """ x = 1.0 - (numpy.log(ic50) / numpy.log(50000)) return numpy.minimum( 1.0, numpy.maximum(0.0, x)) def to_ic50(x): """ Convert regression targets in the range [0.0, 1.0] to ic50s in the range [0, 50000.0]. Parameters ---------- x : numpy.array of float Returns ------- numpy.array of float """ return 50000.0 ** (1.0 - x)