Jovian
⭐️
Sign In
In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
dataset = pd.read_csv('Solar.csv')
In [3]:
from sklearn.tree import DecisionTreeRegressor
X = dataset.iloc[:, 1:7].values
y = dataset.iloc[:, -1].values
In [4]:
reg = DecisionTreeRegressor(criterion="mse",min_samples_leaf=5).fit(X, y)
In [5]:
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
In [6]:
y_pred = reg.predict(X_test)
In [7]:
df = pd.DataFrame({'Actual': y_test.flatten(), 'Predicted': y_pred.flatten()})
In [8]:
dataset.head()
Out[8]:
In [12]:
import requests, json  
api_key = "95050872b5df4419ce572aaf25641984" 
base_url = "http://api.openweathermap.org/data/2.5/weather?"
city_name = input("Enter city name : ")
plant_capacity=int(input("Enter Solar Powerplant capacity:"))
complete_url = base_url + "appid=" + api_key + "&q=" + city_name 
response = requests.get(complete_url)
x = response.json()
if x["cod"] != "404": 
   print("ok") 
else: 
    print(" City Not Found ") 
x
Enter city name : Bangalore Enter Solar Powerplant capacity:1200 ok
Out[12]:
{'coord': {'lon': 77.6, 'lat': 12.98},
 'weather': [{'id': 801,
   'main': 'Clouds',
   'description': 'few clouds',
   'icon': '02n'}],
 'base': 'stations',
 'main': {'temp': 296.59,
  'pressure': 1018,
  'humidity': 78,
  'temp_min': 295.15,
  'temp_max': 298.15},
 'visibility': 6000,
 'wind': {'speed': 2.24, 'deg': 95},
 'clouds': {'all': 20},
 'dt': 1572715483,
 'sys': {'type': 1,
  'id': 9205,
  'country': 'IN',
  'sunrise': 1572655401,
  'sunset': 1572697373},
 'timezone': 19800,
 'id': 1277333,
 'name': 'Bangalore',
 'cod': 200}
In [13]:
def convert_time(dt):
    a=dt[11:16]
    hour=int(a[:2])
    minute=int(a[3:])
    minute_in_percent=((minute/60)*100)/100
    minute_in_percent_three=format(minute_in_percent,'.3f')
    minute_in_percent_three=float(minute_in_percent_three)
    return minute_in_percent_three+hour
In [14]:
y=x['sys']
import time
a=time.ctime(y['sunset'])
c=convert_time(a)
print(c)
17.867
In [3]:
import skfuzzy
In [ ]: