Upload files to "Nam"
This commit is contained in:
39
Nam/model.running_code.py
Normal file
39
Nam/model.running_code.py
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
import pandas as pd
|
||||
import pickle
|
||||
from tensorflow.keras.models import load_model
|
||||
from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score
|
||||
from Feature import extract_url_features
|
||||
import tensorflow as tf
|
||||
|
||||
|
||||
# 4. 스케일러 불러오기
|
||||
with open("scaler.pkl", "rb") as f:
|
||||
scaler = pickle.load(f)
|
||||
|
||||
# 5. 모델 불러오기
|
||||
model = load_model("best_model.h5")
|
||||
|
||||
@tf.function(reduce_retracing=True)
|
||||
def predict_with_model(model, input_data):
|
||||
return model(input_data)
|
||||
|
||||
|
||||
url = input("URL입력 : ")
|
||||
|
||||
features = extract_url_features(url)
|
||||
input_df = pd.DataFrame([list(features.values())], columns= features.keys())
|
||||
|
||||
|
||||
input_scaled = scaler.transform(input_df)
|
||||
|
||||
|
||||
prediction = predict_with_model(model, input_scaled)
|
||||
|
||||
|
||||
# 7. 결과 출력
|
||||
best_threshold = 0.5
|
||||
if prediction[0][0] > best_threshold:
|
||||
print('악')
|
||||
else:
|
||||
print('정')
|
||||
Reference in New Issue
Block a user