-
Notifications
You must be signed in to change notification settings - Fork 320
Description
I have face a big problem when I was using this code for my project.
weather(snowfall) prediction code using python:
code:
import pyttsx3
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeRegressor
def random_data_CSV():
np.random.seed(42)
num_samples = 100
temperature = np.random.randint(-10, 10, num_samples)
humidity = np.random.randint(30, 90, num_samples)
snowfall = np.random.choice([0, 1], num_samples, p=[0.7, 0.3]) # Simulate rainy days (1) and non-rainy days (0)
data = pd.DataFrame({'temperature': temperature, 'humidity': humidity, 'snowfall': snowfall})
data.to_csv('snowfall_random_data.csv', index=False)
def Prediction():
data = pd.read_csv('snowfall_random_data.csv')
X = data[['temperature', 'humidity']]
y = data['snowfall']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = DecisionTreeRegressor()
model.fit(X_train, y_train)
model.predict(X_test)
temp = int(input("Enter the value of temperature in Celsius = "))
humid = int(input("Enter the value of humidity = "))
new_data = pd.DataFrame({'temperature': [temp], 'humidity': [humid]})
predicted_snowfall = model.predict(new_data)
print(
f'Predicted snowfall for temperature = {new_data["temperature"].iloc[0]} and '
f'humidity = {new_data["humidity"].iloc[0]}'
f'?'f'{" Yes" if predicted_snowfall[0] else " No"}')
def repeat():
while True:
print("Welcome to the Simple Snowfall Prediction Software")
print(" Developed by Talha Khalid\n")
print("** Important Note ** \nFor making this software, Talha Khalid has used "
"random generated data for temperature and humidity to train the model.")
tk = pyttsx3.init()
tk.say("Welcome to the Simple Snowfall Prediction Software")
tk.say("Developed by Talha Khalid")
tk.say("Important Note ** \nFor making this software, Talha Khalid has used random generated data for "
"temperature and humidity to train the model")
tk.runAndWait()
Prediction()
user = input("Do you want to use it again? Press Y/N: ").lower()
print("\n")
if user == 'n':
print("Thanks for using. Have a lovely day :)")
break
elif user != 'y':
print("Invalid input. Shutting down the software. Thanks for using. Have a lovely day :)")
break
repeat()
Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
Last 5 Keys:
& Space " C :
Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
Parameter name: left
Actual value was -2.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
Actual value was -2.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
PS F:\presentation\Snowfall-Predictor-main\Snowfall Prediction> & "C:/Users/Shohan Chowdhury/AppData/Local/Microsoft/WindowsApps/python3.11.exe" "f:/presentation/Snowfall-Predictor-main/Snowfall Prediction/main.py"
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
PS F:\presentation\Snowfall-Predictor-main\Snowfall Prediction> & "C:/Users/Shohan Chowdhury/AppData/Local/Microsoft/WindowsApps/python3.11.exe" "f:/presentation/Snowfall-Predictor-main/Snowfall Prediction/main.py"
Welcome to the Simple Snowfall Prediction Software
PS F:\presentation\Snowfall-Predictor-main\Snowfall Prediction> & "C:/Users/Shohan Chowdhury/AppData/Local/Microsoft/WindowsApps/python3.11.exe" "f:/presentation/Snowfall-Predictor-main/Snowfall Prediction/main.py"
Welcome to the Simple Snowfall Prediction Software
py"
Welcome to the Simple Snowfall Prediction Software
Developed by Talha Khalid
** Important Note **
For making this software, Talha Khalid has used random generated data for temperature and humidity to train the model.
Welcome to the Simple Snowfall Prediction Software
Developed by Talha Khalid
** Important Note **
For making this software, Talha Khalid has used random generated data for temperature and humidity to train the model.
Enter the value of temperature in Celsius = 15
Enter the value of humidity = 20
Predicted snowfall for temperature = 15 and humidity = 20? No
Developed by Talha Khalid
** Important Note **
For making this software, Talha Khalid has used random generated data for temperature and humidity to train the model.
Enter the value of temperature in Celsius = 15
Enter the value of humidity = 20
Predicted snowfall for temperature = 15 and humidity = 20? No
For making this software, Talha Khalid has used random generated data for temperature and humidity to train the model.
Enter the value of temperature in Celsius = 15
Enter the value of humidity = 20
Predicted snowfall for temperature = 15 and humidity = 20? No
Do you want to use it again? Press Y/N: Y
Enter the value of temperature in Celsius = 15
Enter the value of humidity = 20
Predicted snowfall for temperature = 15 and humidity = 20? No
Do you want to use it again? Press Y/N: Y
Do you want to use it again? Press Y/N: Y
Welcome to the Simple Snowfall Prediction Software
Developed by Talha Khalid
Welcome to the Simple Snowfall Prediction Software
Developed by Talha Khalid
Developed by Talha Khalid
** Important Note **
Traceback (most recent call last):
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 72, in
repeat()
Traceback (most recent call last):
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 72, in
Traceback (most recent call last): e\local-packages\Python311\site-packages\pyttsx3
Traceback (most recent call last): \engine.py", line 180, in runAndWait
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 72, in
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 72, in
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 72, in
repeat()
repeat()
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 56, in repeat
File "f:\presentation\Snowfall-Predictor-main\Snowfall Prediction\main.py", line 56, in repeat
tk.runAndWait()
File "C:\Users\Shohan Chowdhury\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pyttsx3\engine.py", line 180, in runAndWait
raise RuntimeError('run loop already started')
RuntimeError: run loop already started
PS F:\presentation\Snowfall-Predictor-main\Snowfall Prediction>