<jupyter_start><jupyter_text>1) Enter your zip in cell 42) Retrieves lat, long from zip_code_database3) Predicts GHI from lat, long and returns r-squared value in cells 10 & 11<jupyter_code>import pandas as pd
import pickle
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import r2_score
zips=pd.read_csv('zip_code_database.csv')
zips
# Take user ZIP input with error handling
user_input=input("Enter your ZIP: \n")
print(f'You entered {user_input}')
coords=zips.loc[zips['zip']==int(user_input)][['latitude','longitude']].values
while len(coords)==0:
    print(f'ERROR invalid ZIP: {user_input}')
    user_input=input("Re-enter your ZIP: \n")
    print(f'You entered {user_input}')
    coords=zips.loc[zips['zip']==int(user_input)][['latitude','longitude']].values
coords
df=pd.read_csv('pv_open_2020.csv')
df
X = df[['latitude','longitude']].values
y = df['global_horizontal_irradiance'].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random_state = 0)
regressor = RandomForestRegressor(n_estimators=10)
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
pickle.dump(regressor, open('model.pkl','wb'))
model = pickle.load( open('model.pkl','rb'))
print(model.predict(coords))
r2_score(y_test, y_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14044117647058824, 'fraction_numerical': 0.014705882352941176, 'mean_word_length': 7.780645161290322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '191193', 'license': 'MIT', 'n_tokens_mistral': 523, 'n_tokens_neox': 500, 'n_words': 104, 'path': 'ML/LatLngGHI/GHI_from_coords.ipynb', 'repo_name': 'AKumar1-lab/Final_Project_Team_SunnyDay', 'size': '1360'}