Skip to content

Commit

Permalink
Update AGN & SLSN models for ELASTICC (#353)
Browse files Browse the repository at this point in the history
* Joblib models updated. Pkl file converted to joblib

* AGN classifier now reads joblib

* Fixed path

* Use joblib instead of pickle to load the model
  • Loading branch information
erusseil authored Oct 24, 2023
1 parent 9229c20 commit 612431f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
7 changes: 3 additions & 4 deletions fink_science/agn/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pickle
import joblib
import fink_science.agn.kernel as k
import fink_science.agn.feature_extraction as fe
import os
Expand All @@ -27,7 +27,7 @@
def load_classifier(source):
"""
load the random forest classifier trained to recognize the AGN
on binary cases : AGNs vs non-AGNs (pickle format).
on binary cases : AGNs vs non-AGNs (joblib format).
Parameters
----------
Expand Down Expand Up @@ -58,8 +58,7 @@ def load_classifier(source):
elif source == 'ZTF':
model_path = k.CLASSIFIER_ZTF

with open(model_path, "rb") as f:
clf = pickle.load(f)
clf = joblib.load(model_path)

return clf

Expand Down
4 changes: 2 additions & 2 deletions fink_science/agn/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from fink_science import __file__

curdir = os.path.dirname(os.path.abspath(__file__))
CLASSIFIER_ELASTICC = curdir + "/data/models/AGN_elasticc_alerts.pkl"
CLASSIFIER_ZTF = curdir + "/data/models/AGN_binary.pkl"
CLASSIFIER_ELASTICC = curdir + "/data/models/AGN_elasticc_alerts.joblib"
CLASSIFIER_ZTF = curdir + "/data/models/AGN_binary.joblib"
MINIMUM_POINTS = 4
MAXFEV = 3000
6 changes: 2 additions & 4 deletions fink_science/agn/unit_examples.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import pandas as pd
import numpy as np
import fink_science.agn.kernel as k
import pickle
import joblib


with open(k.CLASSIFIER_ELASTICC, "rb") as f:
clf_unit = pickle.load(f)
clf_unit = joblib.load(k.CLASSIFIER_ELASTICC)

raw_ztf_unit = pd.DataFrame(
{
Expand Down
Binary file not shown.
Binary file removed fink_science/data/models/AGN_elasticc_alerts.pkl
Binary file not shown.
Binary file modified fink_science/data/models/SLSN_elasticc_alerts.joblib
Binary file not shown.

0 comments on commit 612431f

Please sign in to comment.