sid22669 commited on
Commit
4a9c2e6
·
1 Parent(s): 397c5a9

Add application file

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image
2
+ FROM python:3.8-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install any needed dependencies specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port 5000 available to the world outside this container
14
+ EXPOSE 5000
15
+
16
+ # Define environment variable
17
+ ENV NAME Weather
18
+
19
+ # Run app.py when the container launches
20
+ CMD ["python", "app.py"]
21
+
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ import pickle
3
+
4
+ app = Flask(__name__)
5
+
6
+ # Load the trained model
7
+ with open('random_forest_model.pkl', 'rb') as file:
8
+ model = pickle.load(file)
9
+
10
+ @app.route('/')
11
+ def index():
12
+ return render_template('index.html')
13
+
14
+ @app.route('/predict', methods=['POST'])
15
+ def predict():
16
+ # Get input values from the form
17
+ precipitation = float(request.form['precipitation'])
18
+ temp_max = float(request.form['temp_max'])
19
+ temp_min = float(request.form['temp_min'])
20
+ wind = float(request.form['wind'])
21
+
22
+ # Make a prediction using the loaded model
23
+ prediction = model.predict([[precipitation, temp_max, temp_min, wind]])
24
+
25
+ # Pass the prediction result to the result.html page
26
+ return render_template('result.html', prediction=prediction[0])
27
+
28
+ if __name__ == '__main__':
29
+ app.run(debug=True)
random_forest_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:191c1b7a6ccf2d8664c3227f943e097ab71d7b47350990eed39b9df9be0f6eaf
3
+ size 2479262
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask
2
+ pickle
templates/index.html ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Weather Prediction</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f2f2f2;
11
+ margin: 0;
12
+ padding: 0;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ height: 100vh;
17
+ }
18
+
19
+ form {
20
+ background-color: #fff;
21
+ padding: 20px;
22
+ border-radius: 10px;
23
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
24
+ max-width: 400px;
25
+ width: 100%;
26
+ }
27
+
28
+ h2 {
29
+ text-align: center;
30
+ color: #333;
31
+ }
32
+
33
+ label {
34
+ font-weight: bold;
35
+ color: #555;
36
+ }
37
+
38
+ input[type="text"] {
39
+ width: 100%;
40
+ padding: 10px;
41
+ margin-bottom: 15px;
42
+ border: 1px solid #ddd;
43
+ border-radius: 5px;
44
+ box-sizing: border-box;
45
+ }
46
+
47
+ input[type="submit"] {
48
+ background-color: #4caf50;
49
+ color: white;
50
+ padding: 10px 20px;
51
+ border: none;
52
+ border-radius: 5px;
53
+ cursor: pointer;
54
+ transition: background-color 0.3s;
55
+ }
56
+
57
+ input[type="submit"]:hover {
58
+ background-color: #45a049;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body>
63
+ <form action="/predict" method="post">
64
+ <h2>Weather Prediction</h2>
65
+ <label for="precipitation">Precipitation:</label>
66
+ <input type="text" id="precipitation" name="precipitation">
67
+
68
+ <label for="temp_max">Max Temperature:</label>
69
+ <input type="text" id="temp_max" name="temp_max">
70
+
71
+ <label for="temp_min">Min Temperature:</label>
72
+ <input type="text" id="temp_min" name="temp_min">
73
+
74
+ <label for="wind">Wind:</label>
75
+ <input type="text" id="wind" name="wind">
76
+
77
+ <input type="submit" value="Predict">
78
+ </form>
79
+ </body>
80
+ </html>
templates/result.html ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Weather Prediction Result</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f0f9ff; /* Bright background color */
11
+ margin: 0;
12
+ padding: 0;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ height: 100vh;
17
+ }
18
+
19
+ .container {
20
+ background-color: #fff;
21
+ padding: 20px;
22
+ border-radius: 10px;
23
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
24
+ max-width: 400px;
25
+ text-align: center;
26
+ }
27
+
28
+ h2 {
29
+ color: #333;
30
+ margin-bottom: 20px;
31
+ }
32
+
33
+ p {
34
+ font-size: 18px;
35
+ color: #555;
36
+ margin-bottom: 20px;
37
+ }
38
+
39
+ .prediction {
40
+ font-size: 24px;
41
+ font-weight: bold;
42
+ color: #4caf50;
43
+ transition: transform 0.3s, color 0.3s; /* Smooth color and size transition */
44
+ cursor: pointer; /* Add cursor pointer */
45
+ }
46
+
47
+ .prediction:hover {
48
+ color: #008cba; /* Change color on hover */
49
+ transform: scale(1.1); /* Increase size on hover */
50
+ }
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <div class="container">
55
+ <h2>Weather Prediction Result</h2>
56
+ <p>The predicted weather class is: <span class="prediction" id="prediction">Sunny</span></p> <!-- Initial prediction value, you can replace "Sunny" with dynamic content -->
57
+ </div>
58
+ </body>
59
+ </html>