<jupyter_start><jupyter_text>UNITED TRACTOR AS BEST GROWTH STOCK<jupyter_code>import pandas as pd
import numpy as np
from fbprophet import Prophet
import matplotlib.pyplot as plt

from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error

%matplotlib inline
 
plt.rcParams['figure.figsize']=(20,10)
plt.style.use('fivethirtyeight')<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>import pandas_datareader.data as web
import datetime

start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2018, 1, 1)

df = web.DataReader('UNTR', 'google', start, end)

print(df.head())
close = df['Close']<jupyter_output><empty_output><jupyter_text>Plot the data<jupyter_code>close.plot()
close_df = close.reset_index().rename(columns={'Date':'ds', 'Close':'y'})
close_df['y'] = np.log(close_df['y'])<jupyter_output><empty_output><jupyter_text>Using Prophet for Prediction<jupyter_code>model = Prophet()
model.fit(close_df)
future = model.make_future_dataframe(periods=1825) #Forecasting for 5 year from now.
forecast = model.predict(future)
model.plot(forecast)<jupyter_output><empty_output><jupyter_text>Evaluating performence model<jupyter_code>two_years = forecast.set_index('ds').join(df)
two_years = two_years[['Close', 'yhat', 'yhat_upper', 'yhat_lower' ]].dropna().tail(800)
two_years['yhat']=np.exp(two_years.yhat)
two_years['yhat_upper']=np.exp(two_years.yhat_upper)
two_years['yhat_lower']=np.exp(two_years.yhat_lower)
two_years
two_years[['Close', 'yhat']].plot()<jupyter_output><empty_output><jupyter_text>Average Errors<jupyter_code>two_years_AE = (two_years.yhat - two_years.Close)
print(two_years_AE.describe())<jupyter_output>count     800.000000
mean      -13.217759
std      1138.544212
min     -3405.451285
25%      -672.025918
50%        -5.938094
75%       601.081711
max      4564.772005
dtype: float64<jupyter_text>R2 Score<jupyter_code>r2_score(two_years.Close, two_years.yhat)<jupyter_output><empty_output><jupyter_text>Mean Squared Error<jupyter_code>mean_squared_error(two_years.Close, two_years.yhat)<jupyter_output><empty_output><jupyter_text>Mean Absolute Error<jupyter_code>mean_absolute_error(two_years.Close, two_years.yhat)<jupyter_output><empty_output><jupyter_text>Forecasting with y upper and y lower confidence<jupyter_code>fig, ax1 = plt.subplots()
ax1.plot(two_years.Close)
ax1.plot(two_years.yhat)
ax1.plot(two_years.yhat_upper, color='black',  linestyle=':', alpha=0.5)
ax1.plot(two_years.yhat_lower, color='black',  linestyle=':', alpha=0.5)

ax1.set_title('Actual UNTR (Orange) vs UNTR Forecasted Upper & Lower Confidence (Black)')
ax1.set_ylabel('Price')
ax1.set_xlabel('Date')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1372110365398956, 'fraction_numerical': 0.04436987322893363, 'mean_word_length': 8.44718309859155, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '238822', 'license': 'MIT', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1041, 'n_words': 151, 'path': 'stock-prediction/Best Growth Stock Prediction Analysis Using Prophet.ipynb', 'repo_name': 'rubiagatra/stock-ticker-id', 'size': '2682'}