import pandas as pd
import subprocess
subprocess.call(["pip", "install", "scikit-learn"])
subprocess.call(["python", "-m", "pip" ,"install", "--upgrade pip"])
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
import numpy as np

import gradio as gr
#ooooo

df=pd.read_csv('GOOG.csv')
y=df['Close']
p=df.drop('Close',axis=1)
q=p.drop('Date',axis=1)
gw=q.drop('High',axis=1)
g=q.drop('Adj Close',axis=1)
x=g

x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2,random_state=100)

lr=LinearRegression()
lr.fit(x_train,y_train)
y_lr_train_pred=lr.predict(x_train)
y_lr_test_pred=lr.predict(x_test)
def pre(features):
    a = np.array(list(map(float, features.split(","))))

    a_reshaped = a.reshape(1, -1)

    prediction = lr.predict(a_reshaped)

    return prediction[0]

iface = gr.Interface(fn=pre, inputs="text", outputs="text")
iface.launch()