-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab15dcd
commit 3081917
Showing
7 changed files
with
8,078 additions
and
0 deletions.
There are no files selected for viewing
1,412 changes: 1,412 additions & 0 deletions
1,412
Day-12_SUMMER_TRAINING_AIML/Day_12(2)_DHRUVDHAYAL_AI_ML (1).ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,267 changes: 1,267 additions & 0 deletions
1,267
Day-12_SUMMER_TRAINING_AIML/Day_12_DHRUVDHAYAL_AI_ML.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,648 changes: 1,648 additions & 0 deletions
1,648
Day-12_SUMMER_TRAINING_AIML/GM_stock_2018_to_2024.csv
Large diffs are not rendered by default.
Oops, something went wrong.
1,648 changes: 1,648 additions & 0 deletions
1,648
Day-12_SUMMER_TRAINING_AIML/INFOSYS_stock_2018_to_2024 (1).csv
Large diffs are not rendered by default.
Oops, something went wrong.
1,648 changes: 1,648 additions & 0 deletions
1,648
Day-12_SUMMER_TRAINING_AIML/Tesla_stock_2018_to_2024.csv
Large diffs are not rendered by default.
Oops, something went wrong.
188 changes: 188 additions & 0 deletions
188
Day-12_SUMMER_TRAINING_AIML/day_12(2)_dhruvdhayal_ai_ml.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Day-12(2)_DHRUVDHAYAL_AI/ML.ipynb | ||
Automatically generated by Colab. | ||
Original file is located at | ||
https://colab.research.google.com/drive/1apn7PkA9SqHSzEoTXF-adx5smv8OZBO1 | ||
#AUTOMOBILES - GM | ||
""" | ||
|
||
import pandas_datareader as pdr; | ||
import datetime; | ||
import pandas as pd; | ||
|
||
#Showing the Values of the Date by setting up of the Data. | ||
start=datetime.datetime(2018,1,1); | ||
end=datetime.datetime(2024,7,20); | ||
|
||
#Printing the Satrt and the end date. | ||
print("\n 1. Starting Date of the Market: ",start); | ||
print("\n 2. Ending Date of the Market: ",end); | ||
|
||
stock=['GM']; | ||
data=pdr.DataReader(stock,'stooq',str(start.date()),str(end.date())).stack('Symbols'); | ||
data.head(); | ||
|
||
#Reset the Values of the Index. | ||
newData=data.reset_index(); | ||
newData.head(); | ||
|
||
newData.to_csv('/content/GM_stock_2018_to_2024.csv'); | ||
|
||
import matplotlib.pyplot as plt | ||
# plot the close price fo the tesla stock | ||
# load the csv file | ||
GM_data = pd.read_csv('/content/GM_stock_2018_to_2024.csv') | ||
|
||
# set the date as the index | ||
GM_data.set_index('Date',inplace=True) | ||
GM_data.head() | ||
# and then sperate the close price | ||
close_price = GM_data['Close'] | ||
# then plot the close price | ||
close_price.plot(xlabel='Date',ylabel='Price',label='INFY',title='ICICI BANK Stock Price',figsize=(10,6)) | ||
|
||
import matplotlib.pyplot as plt | ||
# plot the close price fo the tesla stock | ||
# load the csv file | ||
GM_data = pd.read_csv('/content/GM_stock_2018_to_2024.csv') | ||
|
||
# set the date as the index | ||
GM_data.set_index('Date',inplace=True) | ||
GM_data.sort_index(ascending=True,inplace=True) | ||
GM_data.head() | ||
# and then sperate the close price | ||
close_price = GM_data['Close'] | ||
# then plot the close price | ||
close_price.plot(xlabel='Date',ylabel='Price',label='INFY',title='ICICI BANK Stock Price',figsize=(10,6)) | ||
|
||
#We, meed to show the values of the Subplot of data: 'SYMBOLS','CLOSE','HIGH','LOW','OPEN'. | ||
import matplotlib.pyplot as plt | ||
import seaborn as sns; | ||
import numpy as np; | ||
|
||
#Now, we have to subplot the values of the graph. | ||
plt.figure(1,figsize=(6,6)); | ||
|
||
plt.subplot(3,1,1); | ||
plt.plot(GM_data['Close'],label='Close Price'); | ||
plt.plot(GM_data['Open'],label='Open Price'); | ||
plt.legend(); | ||
|
||
plt.subplot(3,1,2); | ||
plt.plot(GM_data['High'],label='High Price'); | ||
plt.plot(GM_data['Low'],label='Low Price'); | ||
plt.legend(); | ||
|
||
plt.subplot(3,1,3); | ||
plt.plot(GM_data['Volume'],label='Volume'); | ||
plt.legend(); | ||
|
||
"""# >> Showing the Values of the Moving Averages. ON INFOSYS.""" | ||
|
||
#Showing the Movinf Averages. | ||
GM_data.head(); | ||
|
||
#Now, Calculating the Values of the Moving Average. | ||
# calulate the moving average | ||
GM_data['SMA_20'] = GM_data['Close'].rolling(20).mean() | ||
GM_data['SMA_50'] = GM_data['Close'].rolling(50).mean() | ||
plt.figure(1) | ||
plt.plot(GM_data['Close'],label='close price',linewidth=0.5) | ||
plt.plot(GM_data['SMA_20'],label='20-SMA',linestyle='--') | ||
plt.plot(GM_data['SMA_50'],label='50-SMA',linestyle='--') | ||
|
||
plt.title('Moving average analysis') | ||
plt.legend() | ||
|
||
"""#Relative Strength Index.""" | ||
|
||
!pip install ta; | ||
|
||
import ta; | ||
GM_data['RSI'] = ta.momentum.RSIIndicator(GM_data['Close'], window=14); | ||
GM_data.head(); | ||
|
||
# relative strength index | ||
GM_data['RSI'] = ta.momentum.rsi(GM_data['Close'],window=14) | ||
|
||
plt.figure(1,(12,6)) | ||
plt.plot(GM_data['RSI'],label='RSI',linewidth=0.5) | ||
plt.axhline(70,linestyle='--',color='red',alpha=0.5) | ||
plt.axhline(30,linestyle='--',color='red',alpha=0.5) | ||
plt.title('RSI analysis') | ||
plt.legend(); | ||
GM_data.tail(); | ||
|
||
# prompt: save the file in anther file | ||
|
||
GM_data.to_csv('/content/GM_stock_2018_to_2024_updated.csv') | ||
|
||
"""#Task-2: | ||
--> 1. Consider the 3-Years of Infosys Data. | ||
--> 2. 2018-2019-2020. | ||
--> 3. Try and fit the 'ARIMA' and 'SARIMA'. | ||
--> 4. FORELIST-> 1MONTH DATA. | ||
--> 5. Super in Base of the Actual data. | ||
""" | ||
|
||
#Importing the Inbuilt Libraries. | ||
from statsmodels.tsa import seasonal,arima_model; | ||
import pandas as pd; | ||
import numpy as np; | ||
|
||
#Importing the Values of the Data. | ||
data=pd.read_csv("/content/INFOSYS_stock_2018_to_2024 (1).csv"); | ||
|
||
#printing the Values of the data. | ||
print("\n 1. Total Length of the Data: ",data.shape); | ||
data.head(); | ||
|
||
#Information of the Data Values. | ||
data.info(); | ||
|
||
#Importing the Inbuilt Libraries. | ||
from statsmodels.tsa import seasonal,arima_model | ||
import pandas as pd | ||
import numpy as np | ||
|
||
#Importing the Values of the Data. | ||
data=pd.read_csv("/content/INFOSYS_stock_2018_to_2024 (1).csv") | ||
|
||
# Check the column names of your DataFrame | ||
print(data.columns) | ||
|
||
#Convert the Month Column into Text into the DataTime. | ||
# Adjust the column name below if it's different in your data | ||
data["Date"] = pd.to_datetime(data["Date"]) # Replace 'Month' with the actual column name if needed | ||
data.head() | ||
|
||
data.head(50); | ||
|
||
#Set the Month Column as the Index of the Pandas DataFiles. | ||
data.set_index("Date",inplace=True); | ||
data.head(); | ||
|
||
import matplotlib.pyplot as plt; | ||
data['Close'].plot(); | ||
|
||
#Let's Create the ForeCaster. | ||
import statsmodels.api as st; | ||
|
||
# Assuming 'data' is your time series DataFrame | ||
sarima_model = st.tsa.statespace.SARIMAX(data,order=(1,1,1),seasonal_order=(1,1,1,12)) | ||
|
||
#Train the Model. | ||
sarima_model = sarima_model.fit() | ||
|
||
# forecaste the value | ||
value_for= sarima_model.forecast() | ||
print(value_for) | ||
|
Oops, something went wrong.