-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd90ea3
commit 1dfa8eb
Showing
9 changed files
with
553 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Functions to apply rbscore | ||
""" | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import torch | ||
from torch import nn | ||
from winterrb.utils import make_triplet | ||
|
||
# ML_KEYS = | ||
|
||
|
||
def apply_rb_to_table(model: nn.Module, table: pd.DataFrame) -> pd.DataFrame: | ||
""" | ||
Apply the realbogus score to a table of sources | ||
:param model: Pytorch model | ||
:param table: Table of sources | ||
:return: Table of sources with realbogus score | ||
""" | ||
|
||
rb_scores = [] | ||
|
||
for _, row in table.iterrows(): | ||
triplet = make_triplet(row, normalize=True) | ||
triplet_reshaped = np.transpose(np.expand_dims(triplet, axis=0), (0, 3, 1, 2)) | ||
with torch.no_grad(): | ||
outputs = model(torch.from_numpy(triplet_reshaped)) | ||
|
||
rb_scores.append(float(outputs[0])) | ||
|
||
table["rb"] = rb_scores | ||
|
||
return table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" | ||
Module for machine learning models | ||
""" | ||
|
||
from mirar.processors.sources.machine_learning.pytorch import Pytorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.