Skip to content

Commit 64e3aed

Browse files
Update ml-code-optimiser.py
1 parent ea5bd52 commit 64e3aed

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/backend/neploy-build-python/ml-code-optimiser.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This code first reads the Python smart contract script from a file. Then, it uses the model to predict the suggested improvements for the smart contract code. Finally, it prints the suggested improvements
2-
31
import numpy as np
42
import pandas as pd
53
from sklearn.model_selection import train_test_split
@@ -42,14 +40,14 @@
4240
lines = code.split("\n")
4341

4442
# Predict the improvement suggestions for each line of code
45-
for line in lines:
43+
for i, line in enumerate(lines):
4644
new_code_vectorized = vectorizer.transform([line])
4745
prediction = model.predict(new_code_vectorized)[0]
4846

4947
# Print the improvement suggestions
5048
if prediction == "optimize":
51-
print("The following are the suggested optimization snippets for line {}:".format(line))
49+
print("Line {}: The following are the suggested optimization snippets:".format(i + 1))
5250
for snippet in model.predict_proba(new_code_vectorized)[0]:
5351
print(snippet)
5452
else:
55-
print("The code in line {} is fine.".format(line))
53+
print("Line {}: The code is fine.".format(i + 1))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy