Views
No views yet
| Metric | Value |
|---|---|
| roc_auc | 0.986844 |
| accuracy | 0.948568 |
| f1 | 0.948623 |
| precision | 0.947619 |
| recall | 0.949629 |
1import numpy as np
2import onnxruntime
3from huggingface_hub import hf_hub_download
4
5REPO_ID = "pirocheto/phishing-url-detection"
6FILENAME = "model.onnx"
7model_path = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
8
9# Initializing the ONNX Runtime session with the pre-trained model
10sess = onnxruntime.InferenceSession(
11 model_path,
12 providers=["CPUExecutionProvider"],
13)
14
15urls = [
16 "https://clubedemilhagem.com/home.php",
17 "http://www.medicalnewstoday.com/articles/188939.php",
18]
19inputs = np.array(urls, dtype="str")
20
21# Using the ONNX model to make predictions on the input data
22results = sess.run(None, {"inputs": inputs})[1]
23
24for url, proba in zip(urls, results):
25 print(f"URL: {url}")
26 print(f"Likelihood of being a phishing site: {proba[1] * 100:.2f} %")
27 print("----")
281const ort = require('onnxruntime-node');
2
3async function main() {
4
5 try {
6 // Make sure you have downloaded the model.onnx
7 // Creating an ONNX inference session with the specified model
8 const model_path = "./model.onnx";
9 const session = await ort.InferenceSession.create(model_path);
10
11 const urls = [
12 "https://clubedemilhagem.com/home.php",
13 "http://www.medicalnewstoday.com/articles/188939.php",
14 ]
15
16 // Creating an ONNX tensor from the input data
17 const tensor = new ort.Tensor('string', urls, [urls.length,]);
18
19 // Executing the inference session with the input tensor
20 const results = await session.run({"inputs": tensor});
21 const probas = results['probabilities'].data;
22
23 // Displaying results for each URL
24 urls.forEach((url, index) => {
25 const proba = probas[index * 2 + 1];
26 const percent = (proba * 100).toFixed(2);
27
28 console.log(`URL: ${url}`);
29 console.log(`Likelihood of being a phishing site: ${percent}%`);
30 console.log("----");
31 });
32
33 } catch (e) {
34 console.log(`failed to inference ONNX model: ${e}.`);
35 }
36};
37
38main();1<!DOCTYPE html>
2<html>
3 <header>
4 <title>Get Started with JavaScript</title>
5 </header>
6 <body>
7 <!-- import ONNXRuntime Web from CDN -->
8 <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
9 <script>
10 // use an async context to call onnxruntime functions.
11 async function main() {
12 try {
13 const model_path = "./model.onnx";
14 const session = await ort.InferenceSession.create(model_path);
15
16 const urls = [
17 "https://clubedemilhagem.com/home.php",
18 "http://www.medicalnewstoday.com/articles/188939.php",
19 ];
20
21 // Creating an ONNX tensor from the input data
22 const tensor = new ort.Tensor("string", urls, [urls.length]);
23
24 // Executing the inference session with the input tensor
25 const results = await session.run({ inputs: tensor });
26 const probas = results["probabilities"].data;
27
28 // Displaying results for each URL
29 urls.forEach((url, index) => {
30 const proba = probas[index * 2 + 1];
31 const percent = (proba * 100).toFixed(2);
32
33 document.write(`URL: ${url} <br>`);
34 document.write(
35 `Likelihood of being a phishing site: ${percent} % <br>`
36 );
37 document.write("---- <br>");
38 });
39 } catch (e) {
40 document.write(`failed to inference ONNX model: ${e}.`);
41 }
42 }
43 main();
44 </script>
45 </body>
46</html>1import joblib
2from huggingface_hub import hf_hub_download
3
4REPO_ID = "pirocheto/phishing-url-detection"
5FILENAME = "model.pkl"
6
7# Download the model from the Hugging Face Model Hub
8model_path = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
9
10urls = [
11 "https://clubedemilhagem.com/home.php",
12 "http://www.medicalnewstoday.com/articles/188939.php",
13]
14
15# Load the downloaded model using joblib
16model = joblib.load(model_path)
17
18# Predict probabilities for each URL
19probas = model.predict_proba(urls)
20
21for url, proba in zip(urls, probas):
22 print(f"URL: {url}")
23 print(f"Likelihood of being a phishing site: {proba[1] * 100:.2f} %")
24 print("----")
25