当前位置: 首页>>代码示例>>Python>>正文


Python Parameter.checkFloat方法代码示例

本文整理汇总了Python中sandbox.util.Parameter.Parameter.checkFloat方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.checkFloat方法的具体用法?Python Parameter.checkFloat怎么用?Python Parameter.checkFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sandbox.util.Parameter.Parameter的用法示例。


在下文中一共展示了Parameter.checkFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setWeight

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def setWeight(self, weight):
     """
     :param weight: the weight on the positive examples between 0 and 1 (the negative weight is 1-weight)
     :type weight: :class:`float`
     """
     Parameter.checkFloat(weight, 0.0, 1.0)
     self.weight = weight
开发者ID:kentwang,项目名称:sandbox,代码行数:9,代码来源:AbstractWeightedPredictor.py

示例2: setSampleSize

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def setSampleSize(self, sampleSize):
     """
     :param sampleSize: The number of examples to randomly sample for each tree.
     :type sampleSize: :class:`int`
     """
     Parameter.checkFloat(sampleSize, 0.0, 1.0)
     self.sampleSize = sampleSize
开发者ID:charanpald,项目名称:sandbox,代码行数:9,代码来源:TreeRankForest.py

示例3: __init__

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def __init__(self, kernel, tau1, tau2):
     Parameter.checkFloat(tau1, 0.0, float('inf'))
     Parameter.checkFloat(tau2, 0.0, float('inf'))
     Parameter.checkClass(kernel, AbstractKernel)
     self.tau1 = tau1
     self.tau2 = tau2
     self.kernel = kernel
开发者ID:charanpald,项目名称:sandbox,代码行数:9,代码来源:PrimalDualCCARegression.py

示例4: setErrorCost

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def setErrorCost(self, errorCost):
     """
     The penalty on errors on positive labels. The penalty for negative labels
     is 1.
     """
     Parameter.checkFloat(errorCost, 0.0, 1.0)
     self.errorCost = errorCost
开发者ID:kentwang,项目名称:sandbox,代码行数:9,代码来源:LibSVM.py

示例5: generateGraph

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def generateGraph(self, alpha, p, dim):
        Parameter.checkFloat(alpha, 0.0, float('inf'))
        Parameter.checkFloat(p, 0.0, 1.0)
        Parameter.checkInt(dim, 0, float('inf'))
        
        numVertices = self.graph.getNumVertices()
        self.X = numpy.random.rand(numVertices, dim)

        D = KernelUtils.computeDistanceMatrix(numpy.dot(self.X, self.X.T))
        P = numpy.exp(-alpha * D)
        diagIndices = numpy.array(list(range(0, numVertices)))
        P[(diagIndices, diagIndices)] = numpy.zeros(numVertices)

        B = numpy.random.rand(numVertices, numVertices) <= P 

        #Note that B is symmetric - could just go through e.g. upper triangle 
        for i in range(numpy.nonzero(B)[0].shape[0]):
            v1 = numpy.nonzero(B)[0][i]
            v2 = numpy.nonzero(B)[1][i]
            
            self.graph.addEdge(v1, v2)

        erdosRenyiGenerator = ErdosRenyiGenerator(p)
        self.graph = erdosRenyiGenerator.generate(self.graph, False)

        return self.graph
开发者ID:charanpald,项目名称:sandbox,代码行数:28,代码来源:GeometricRandomGenerator.py

示例6: shuffleSplit

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def shuffleSplit(repetitions, numExamples, trainProportion=None):
        """
        Random permutation cross-validation iterator. The training set is sampled
        without replacement and of size (repetitions-1)/repetitions of the examples,
        and the test set represents the remaining examples. Each repetition is
        sampled independently.

        :param repetitions: The number of repetitions to perform.
        :type repetitions: :class:`int`

        :param numExamples: The number of examples.
        :type numExamples: :class:`int`

        :param trainProp: The size of the training set relative to numExamples, between 0 and 1 or None to use (repetitions-1)/repetitions
        :type trainProp: :class:`int`
        """
        Parameter.checkInt(numExamples, 2, float('inf'))
        Parameter.checkInt(repetitions, 1, float('inf'))
        if trainProportion != None:
            Parameter.checkFloat(trainProportion, 0.0, 1.0)

        if trainProportion == None:
            trainSize = int((repetitions-1)*numExamples/repetitions)
        else:
            trainSize = int(trainProportion*numExamples)

        idx = [] 
        for i in range(repetitions):
            inds = numpy.random.permutation(numExamples)
            trainInds = inds[0:trainSize]
            testInds = inds[trainSize:]
            idx.append((trainInds, testInds))
        return idx 
开发者ID:charanpald,项目名称:sandbox,代码行数:35,代码来源:Sampling.py

示例7: binaryBootstrapError

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def binaryBootstrapError(testY, predTestY, trainY, predTrainY, weight):
        """
        Evaluate an error in conjunction with a bootstrap method by computing
        w*testErr + (1-w)*trainErr
        """
        Parameter.checkFloat(weight, 0.0, 1.0)

        return weight*Evaluator.binaryError(testY, predTestY) + (1-weight)*Evaluator.binaryError(trainY, predTrainY)
开发者ID:charanpald,项目名称:sandbox,代码行数:10,代码来源:Evaluator.py

示例8: __init__

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def __init__(self, kernelX, tau1, tau2):
        Parameter.checkFloat(tau1, 0.0, 1.0)
        Parameter.checkFloat(tau2, 0.0, 1.0)
        Parameter.checkClass(kernelX, AbstractKernel)

        self.kernelX = kernelX
        self.tau1 = tau1
        self.tau2 = tau2
开发者ID:charanpald,项目名称:sandbox,代码行数:10,代码来源:PrimalDualCCA.py

示例9: setC

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def setC(self, C):
        try:
            from sklearn.svm import SVC
        except:
            raise
        Parameter.checkFloat(C, 0.0, float("inf"))

        self.C = C
        self.__updateParams()
开发者ID:kentwang,项目名称:sandbox,代码行数:11,代码来源:LibSVM.py

示例10: setInfected

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def setInfected(self, vertexInd, time):
        Parameter.checkIndex(vertexInd, 0, self.getNumVertices())
        Parameter.checkFloat(time, 0.0, float('inf'))

        if self.V[vertexInd, HIVVertices.stateIndex] == HIVVertices.infected:
            raise ValueError("Person is already infected")

        self.V[vertexInd, HIVVertices.stateIndex] = HIVVertices.infected
        self.V[vertexInd, HIVVertices.infectionTimeIndex] = time
开发者ID:charanpald,项目名称:wallhack,代码行数:11,代码来源:HIVVertices.py

示例11: setB

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def setB(self, b):
        """
        Set the b parameter.

        :param b: kernel bias parameter.
        :type b: :class:`float`
        """
        Parameter.checkFloat(b, 0.0, float('inf'))

        self.b = b
开发者ID:charanpald,项目名称:sandbox,代码行数:12,代码来源:PolyKernel.py

示例12: setFeatureSize

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def setFeatureSize(self, featureSize):
        """
        Set the number of features to use for node computation.

        :param featureSize: the proportion of features to randomly select to compute each node. If none then use sqrt(X.shape[1]) features. 
        :type featureSize: :class:`float`
        """
        if featureSize != None: 
            Parameter.checkFloat(featureSize, 0.0, 1.0)
        self.featureSize = featureSize
开发者ID:charanpald,项目名称:sandbox,代码行数:12,代码来源:AbstractTreeRank.py

示例13: createDiscTruncNormParam

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def createDiscTruncNormParam(self, sigma, mode, upper, lower=0):
     """
     Discrete truncated norm parameter 
     """
     Parameter.checkFloat(sigma, 0.0, float('inf'))
     Parameter.checkFloat(mode, 0.0, float('inf'))
     a = (lower-mode)/sigma
     b = (upper-mode)/sigma
     priorDist = lambda: round(stats.truncnorm.rvs(a, b, loc=mode, scale=sigma))
     priorDensity = lambda x: stats.truncnorm.pdf(x, a, b, loc=mode, scale=sigma)
     return priorDist, priorDensity 
开发者ID:charanpald,项目名称:wallhack,代码行数:13,代码来源:HIVABCParameters.py

示例14: createTruncNormParam

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
 def createTruncNormParam(self, sigma, mode):
     """
     Truncated norm parameter between 0 and 1 
     """
     Parameter.checkFloat(sigma, 0.0, 1.0)
     Parameter.checkFloat(mode, 0.0, float('inf'))
     a = -mode/sigma
     b = (1-mode)/sigma
     priorDist = lambda: stats.truncnorm.rvs(a, b, loc=mode, scale=sigma)
     priorDensity = lambda x: stats.truncnorm.pdf(x, a, b, loc=mode, scale=sigma)
     return priorDist, priorDensity 
开发者ID:charanpald,项目名称:wallhack,代码行数:13,代码来源:HIVABCParameters.py

示例15: setDetected

# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkFloat [as 别名]
    def setDetected(self, vertexInd, time, detectionType):
        Parameter.checkIndex(vertexInd, 0, self.getNumVertices())
        Parameter.checkFloat(time, 0.0, float('inf'))

        if detectionType not in [HIVVertices.randomDetect, HIVVertices.contactTrace]:
             raise ValueError("Invalid detection type : " + str(detectionType))

        if self.V[vertexInd, HIVVertices.stateIndex] != HIVVertices.infected:
            raise ValueError("Person must be infected to be detected")

        self.V[vertexInd, HIVVertices.stateIndex] = HIVVertices.removed
        self.V[vertexInd, HIVVertices.detectionTimeIndex] = time
        self.V[vertexInd, HIVVertices.detectionTypeIndex] = detectionType
开发者ID:charanpald,项目名称:wallhack,代码行数:15,代码来源:HIVVertices.py


注:本文中的sandbox.util.Parameter.Parameter.checkFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。