AI, ML, and Deep Learning Videos & Sample Python Program

Project weather Prediction: Using: AI, ML, Deep Learning and Training data (Program in Python)

Project weather Prediction: Using: AI, ML, Deep Learning and Training data (Program in Python)

1. Gather sample weather data (historical data) to train our model.

2. Train a weather prediction model using the sample data.

3. Use the trained model to predict the weather for new data.

4. Display the predictions in a result table.

 

Since it's not practical to train a complete machine learning model here due to limitations, we'll create a simplified version of the weather prediction program using random data. We'll use a basic rule-based approach for weather prediction.

 

Let's proceed with the code:

 

```python

import pandas as pd

import random

 

# Generate sample weather data

def generate_sample_data(num_days=30):

weather_data = {

        "Day": [],

        "Temperature (Celsius)": [],

        "Humidity (%)": [],

        "Rainfall (mm)": [],

}

for i in range(num_days):

        weather_data["Day"].append(f"Day {i+1}")

        weather_data["Temperature (Celsius)"].append(random.uniform(15, 35))

        weather_data["Humidity (%)"].append(random.randint(30, 80))

        weather_data["Rainfall (mm)"].append(random.uniform(0, 20))

return pd.DataFrame(weather_data)

 

# Simple weather prediction function (dummy prediction)

def predict_weather(temperature, humidity, rainfall):

if temperature > 28 and humidity > 60:

     return "Hot and Humid"

elif temperature < 20 and rainfall > 10:

     return "Cold with Heavy Rainfall"

elif temperature < 20:

     return "Cool"

elif rainfall > 5:

     return "Rainy"

else:

     return "Moderate"

 

if __name__ == "__main__":

num_days = 30

weather_data = generate_sample_data(num_days)

 

# Add weather predictions

    weather_data["Prediction"] = [

        predict_weather(temp, humidity, rainfall)

     for temp, humidity, rainfall in zip(

            weather_data["Temperature (Celsius)"],

            weather_data["Humidity (%)"],

            weather_data["Rainfall (mm)"],

     )

]

 

    print("Weather Data with Predictions:")

    print(weather_data)

```

 

This code will generate a DataFrame containing sample weather data for 30 days, including columns for day number, temperature, humidity, rainfall, and a prediction column based on simple logic for weather prediction.

 

The prediction logic is just a basic example, and you would need to use more advanced machine learning techniques with real-world data for accurate predictions in an actual project. However, this should serve as a starting point for you to build upon for more sophisticated models.