Giter VIP home page Giter VIP logo

Comments (2)

tanjimin avatar tanjimin commented on July 26, 2024

Hi @My-laniaKeA . The evaluation code is not well documented so I did not to release them here.

For the correlation metrics I pasted the file here:

import numpy as np
from scipy.stats import pearsonr, spearmanr
import insulation as insu
from tqdm import tqdm

def mse(preds, targets):
    mse = ((preds - targets) ** 2).mean(axis = (1, 2))
    results = list(mse.astype(float))
    return results

def insulation_pearson(preds, targets):
    scores = []
    for pred, target in zip(preds, tqdm(targets)):
        pred_insu = np.array(insu.chr_score(pred))
        label_insu = np.array(insu.chr_score(target))
        nas = np.logical_or(np.isnan(pred_insu), np.isnan(label_insu))
        if nas.sum() == len(pred):
            scores.append(np.nan)
        else:
            metric, p_val = pearsonr(pred_insu[~nas], label_insu[~nas])
            scores.append(metric)
    results = scores
    return results

def observed_vs_expected_with_means(preds, targets, preds_mean, targets_mean):
    scores = []
    for pred, target in zip(preds - preds_mean, tqdm(targets - targets_mean)):
        metric, p_val = pearsonr(pred.reshape(-1), target.reshape(-1))
        scores.append(metric)
    results = scores
    return results

def observed_vs_expected(preds, targets):
    scores = []
    preds_mean = preds.mean(axis = 0, keepdims = True)
    targets_mean = targets.mean(axis = 0, keepdims = True)
    for pred, target in zip(preds - preds_mean, tqdm(targets - targets_mean)):
        metric, p_val = pearsonr(pred.reshape(-1), target.reshape(-1))
        scores.append(metric)
    results = scores
    return results

def distance_stratified_correlation(preds, targets):
    scores = []
    for pred, target in zip(preds, tqdm(targets)):
        distance_list = []
        for dis_i in range(len(pred)):
            pred_diag_i = np.diagonal(pred, offset = dis_i)
            target_diag_i = np.diagonal(target, offset = dis_i)
            if len(pred_diag_i) < 2: break
            metric, p_val = pearsonr(pred_diag_i, target_diag_i)
            distance_list.append(metric)
        scores.append(distance_list)
    results = scores
    return results

If you want the full evaluation pipeline, feel free to shoot me an email ([email protected]) and I can email them over!

from c.origami.

My-laniaKeA avatar My-laniaKeA commented on July 26, 2024

Thank you so much.

from c.origami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.