コード例 #1
0
ファイル: util.py プロジェクト: breckuh/deepimpute
def score_model(model, data, metric, cols=None):
    # Create masked array
    if cols is None:
        cols = data.columns

    maskedData = MaskedArray(data=data)
    maskedData.generate()
    maskedDf = pd.DataFrame(maskedData.getMaskedMatrix(),
                            index=data.index,
                            columns=data.columns)
    # Predict
    # model.fit(maskedDf)
    imputed = model.predict(maskedDf)

    imputedGenes = np.intersect1d(cols, imputed.columns)

    # Compare imputed masked array and input
    maskedIdx = maskedDf[imputedGenes].values != data[imputedGenes].values
    score_res = metric(data[imputedGenes].values[maskedIdx],
                       imputed[imputedGenes].values[maskedIdx])
    return score_res
コード例 #2
0
 def test_generate(self):
     rawData = test_data.rawData
     m_df = MaskedArray(data=rawData, dropout=0.1)
     m_df.generate()