googlestocks / app.py
samarthv's picture
Update app.py
d7e31be
raw
history blame
826 Bytes
import streamlit as st
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
# Load the stock data from the CSV file
data = pd.read_csv('Google_test_data.csv')
# Prepare the data for prediction
X = np.arange(len(data)).reshape(-1, 1)
y = data['Close']
# Train the linear regression model
model = LinearRegression()
model.fit(X, y)
# Predict the stock prices
predictions = model.predict(X)
# Plot the actual and predicted stock prices
plt.plot(data['Date'], y, label='Actual')
plt.plot(data['Date'], predictions, label='Predicted')
plt.xlabel('Date')
plt.ylabel('Stock Price')
plt.title('Google Stock Price Prediction')
plt.legend()
# Remove the Streamlit default layout
st.set_page_config(layout="wide")
# Display the graph in Streamlit
st.pyplot(plt)