def spec(windowSize, stepSize, input, fftMag, sr):

    windowSize = int(windowSize)
    stepSize = int(stepSize)
    numberOfSteps = int(math.floor((len(input) - windowSize) / stepSize) + 1)
    spectrogram = np.zeros((int(fftMag / 2), numberOfSteps))
    timeArray = np.zeros((numberOfSteps))
    for i in range(numberOfSteps):
        currentWindow = input[stepSize * i:(stepSize * i) + windowSize]
        transformedWindow = scipy.fft.fft(currentWindow, n=fftMag)
        truncatedWindow = transformedWindow[:int(fftMag / 2)]
        spectrogram[:, i] = np.log(np.abs(truncatedWindow) + 1)
        timeArray[i] = (stepSize * i + (stepSize * i + windowSize)) / (2 * sr)
    return spectrogram, timeArray
コード例 #2
0
    # 'ks': KS值
    fpr, tpr, thresholds = roc_curve(true, score)
    ks_value = max(tpr - fpr)
    print('ks: ', ks_value)
    return ks_value


ks_calc_auc(y_test, y_score)

# 建立评分卡
# print('coe:', coe)

# 假设好坏比为20的时候分数为600分,每高20分好坏比翻一倍
# 现在求每个变量不同woe值对应的分数刻度可得:

factor = 20 / np.log(2)
offset = 600 - 20 * np.log(20) / np.log(2)


def get_score(Coe, woe, Factor):
    scores = []
    for w in woe:
        score = round(Coe * w * Factor, 0)
        scores.append(score)
    return scores


x1 = get_score(coe[0][0], x_test['RevolvingUtilizationOfUnsecuredLines'],
               factor)
x2 = get_score(coe[0][1], x_test['age'], factor)
x3 = get_score(coe[0][2], x_test['NumberOfTime30-59DaysPastDueNotWorse'],
コード例 #3
0
ファイル: __init__.py プロジェクト: waffleSheep/phyton
 def electrical_conductivity(T):
     return 1e6 / (28.9 - 18.8 * np.exp(-(np.log(T / 1023.0) / 2.37)**2))
コード例 #4
0
 def calculateBIC(self, n, k, Lhat):
     result = np.log(
         n) * k - 2 * Lhat  # Lhat is already the log of the likelihood
     return result