This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X=df1[['Temperature', 'Pressure', 'Humidity', 'Speed', | |
'DayLengthinsec', 'time_in_sec', 'Temp_multiply_humid', 'Month', | |
'wind_dir','Day_of_month']] | |
Y=df1.Radiation | |
X_train, X_test, Y_train, Y_test= train_test_split(X, Y, random_state= 0) | |
def model_score_error(model): | |
prepared_model=model.fit(X_train, Y_train) | |
x=prepared_model.score(X_test,Y_test) | |
print('Score: ',x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.tree import DecisionTreeRegressor | |
from sklearn.neural_network import MLPRegressor | |
from sklearn.linear_model import ElasticNet, Lasso, BayesianRidge, LassoLarsIC | |
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor | |
from sklearn.pipeline import make_pipeline | |
from sklearn.preprocessing import RobustScaler | |
from sklearn.base import BaseEstimator, TransformerMixin, RegressorMixin, clone | |
from sklearn.model_selection import KFold, cross_val_score, train_test_split | |
from sklearn.metrics import mean_squared_error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, ax = plt.subplots() | |
ax.scatter(x = df1['Speed'], y = df1['Radiation']) | |
plt.ylabel('Radiation', fontsize=13) | |
plt.xlabel('Speed', fontsize=13) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1 = df1.drop(df1[(df1['Radiation']>1400)].index) | |
df1 = df1.drop(df1[(df1['wind_dir']>8000)].index) | |
fig, ax = plt.subplots() | |
ax.scatter(x = df1['DayLengthinsec'], y = df1['Radiation']) | |
plt.ylabel('Radiation', fontsize=13) | |
plt.xlabel('DayLengthinsec', fontsize=13) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, ax = plt.subplots() | |
ax.scatter(x = df1['DayLengthinsec'], y = df1['Radiation']) | |
plt.ylabel('Radiation', fontsize=13) | |
plt.xlabel('DayLengthinsec', fontsize=13) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1.hist(figsize=(10,10)) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#We drop the following columns | |
df1 = df1.drop(['Time'], axis=1) | |
from sklearn.model_selection import train_test_split | |
X=df1[['Temperature', 'Pressure', 'Humidity', 'Speed', | |
'DayLengthinsec', 'time_in_sec', 'Temp_multiply_humid', 'Month', | |
'wind_dir','Day_of_month']] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Temp_multiply_humid=df1.Humidity *df1.Temperature | |
df1['Temp_multiply_humid']=Temp_multiply_humid | |
df1['Month']=[d.split('/')[0] for d in df1.Data] | |
df1['Day_of_month']=[d.split('/')[1] for d in df1.Data] | |
df1['wind_dir'] = df1['WindDirection(Degrees)'] | |
#We drop the following columns | |
df1 = df1.drop(['UNIXTime','Data','TimeSunRise','TimeSunSet','WindDirection(Degrees)'], axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model=smf.ols('Radiation ~ Temperature+ Humidity +Humidity*Temperature', df1) | |
Fitting_results=model.fit() | |
print(Fitting_results.summary().tables[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# graph is plotted between time and radiation | |
# it comes out as perfectly skewed | |
plt.scatter(df1.time_in_sec,df1.Radiation,color='blue') | |
plt.xlabel("time_in_sec") | |
plt.ylabel("Radiation") | |
plt.title("Graph") | |
plt.show() |