<gh_stars>10-100
import os
import sys

import lightgbm as lgb
import numpy as np

from malware_rl.envs.utils.ember import PEFeatureExtractor

module_path = os.path.split(os.path.abspath(sys.modules[__name__].__file__))[0]

try:
    model_path = os.path.join(module_path, "sorel.model")
except ValueError:
    print("The model path provide does not exist")


class SorelModel:
    def __init__(self):
        self.model = lgb.Booster(model_file=model_path)
        self.threshold = 0.8336  # Ember 1% FPR
        self.feature_version = 2
        self.extractor = PEFeatureExtractor(self.feature_version)

    def extract(self, bytez):
        return np.array(self.extractor.feature_vector(bytez), dtype=np.float32)

    def predict_sample(self, features):
        return self.model.predict([features])[0]

import os
import sys

import lightgbm as lgb
import numpy as np

from malware_rl.envs.utils.ember import PEFeatureExtractor

module_path = os.path.split(os.path.abspath(sys.modules[__name__].__file__))[0]

try:
    model_path = os.path.join(module_path, "sorel.model")
except ValueError:
    print("The model path provide does not exist")


class SorelModel:
    def __init__(self):
        self.model = lgb.Booster(model_file=model_path)
        self.threshold = 0.8336  # Ember 1% FPR
        self.feature_version = 2
        self.extractor = PEFeatureExtractor(self.feature_version)

    def extract(self, bytez):
        return np.array(self.extractor.feature_vector(bytez), dtype=np.float32)

    def predict_sample(self, features):
        return self.model.predict([features])[0]
# Ember 1% FPR