app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
'num_students': [500, 600, 700, 800, 900],
|
4 |
-
'temperature': [20, 21, 22, 23, 24],
|
5 |
-
'num_rooms': [30, 35, 40, 45, 50]
|
6 |
-
}
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# Calculate the coefficients using normal equations
|
13 |
-
XTX = [[sum(x[i] * x[j] for x in X) for j in range(len(X[0]))] for i in range(len(X[0]))]
|
14 |
-
XTy = [sum(X[i][j] * y[i] for i in range(len(X))) for j in range(len(X[0]))]
|
15 |
-
|
16 |
-
coefficients = [0] * len(X[0])
|
17 |
-
for i in range(len(X[0])):
|
18 |
-
coefficients[i] = sum(XTX[i][j] * XTy[j] for j in range(len(X[0])))
|
19 |
-
|
20 |
-
# Print the coefficients
|
21 |
-
print("Coefficients:", coefficients)
|
22 |
|
23 |
# Values for the new scenario
|
24 |
-
new_students =int(input("
|
25 |
-
new_temperature =int(input("
|
26 |
|
27 |
# Create the feature array for the new scenario
|
28 |
new_scenario = [1, new_students, new_temperature]
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Make the prediction
|
31 |
-
|
|
|
|
|
|
|
32 |
|
|
|
33 |
print("Number of students:", new_students)
|
34 |
print("Temperature:", new_temperature)
|
35 |
print("Predicted number of rooms:", predicted_rooms)
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
# Load the model and tokenizer
|
5 |
+
model_name = "your_model_name" # Replace with the name of the model you want to use
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Values for the new scenario
|
10 |
+
new_students = int(input("Enter new number of students: ")) # Number of students in the new scenario
|
11 |
+
new_temperature = int(input("Enter new temperature: ")) # Temperature in the new scenario
|
12 |
|
13 |
# Create the feature array for the new scenario
|
14 |
new_scenario = [1, new_students, new_temperature]
|
15 |
|
16 |
+
# Convert the input to tokens
|
17 |
+
inputs = tokenizer.encode_plus(
|
18 |
+
"Number of students: {}, Temperature: {}".format(new_students, new_temperature),
|
19 |
+
add_special_tokens=True,
|
20 |
+
padding="max_length",
|
21 |
+
truncation=True,
|
22 |
+
max_length=64,
|
23 |
+
return_tensors="pt"
|
24 |
+
)
|
25 |
+
|
26 |
# Make the prediction
|
27 |
+
with torch.no_grad():
|
28 |
+
outputs = model(**inputs)
|
29 |
+
logits = outputs.logits
|
30 |
+
predicted_rooms = torch.argmax(logits).item()
|
31 |
|
32 |
+
# Print the results
|
33 |
print("Number of students:", new_students)
|
34 |
print("Temperature:", new_temperature)
|
35 |
print("Predicted number of rooms:", predicted_rooms)
|