import numpy as np import pandas as pd import matplotlib.pyplot as plt import gradio as gr ad_data = pd.read_csv("Advertising.csv") ad_data.drop("Unnamed: 0", axis = 1, inplace = True) X = ad_data.drop("sales", axis = 1) y = ad_data["sales"] from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) from sklearn.linear_model import LinearRegression lr = LinearRegression() lr.fit(X_train, y_train) def show_prediction(tv, radio, newspaper): new_df = pd.DataFrame({"TV" : tv, "radio" : radio, "newspaper" : newspaper}, index = [0]) y_pred = lr.predict(new_df) return y_pred demo = gr.Interface( show_prediction, [ "number", "number", "number" ], "number" ) demo.launch()