Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import statsmodels.api as sm
|
| 4 |
+
from sklearn.preprocessing import StandardScaler
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
with open ("scaled_obj.pkl", "rb") as f:
|
| 8 |
+
sc_object = pickle.load(f)
|
| 9 |
+
|
| 10 |
+
with open ("scaled_model.pkl", "rb") as f:
|
| 11 |
+
lin_model_object = pickle.load(f)
|
| 12 |
+
|
| 13 |
+
def fn_predict(Total_Revenue,Operating_Cost,Total_Assets,Total_Liabilities,Stock_Price,Market_Cap,EBITDA,RD_Expenses,Number_of_Employees):
|
| 14 |
+
df = np.array([[Total_Revenue,Operating_Cost,Total_Assets,Total_Liabilities,Stock_Price,Market_Cap,EBITDA,RD_Expenses,Number_of_Employees]])
|
| 15 |
+
scaled_new_data = sc_object.transform(df)
|
| 16 |
+
|
| 17 |
+
predictions = lin_model_object.predict(scaled_new_data)
|
| 18 |
+
return predictions
|
| 19 |
+
|
| 20 |
+
# Define Gradio interface
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=fn_predict,
|
| 23 |
+
inputs=[
|
| 24 |
+
gr.Number(label="Total Revenue"),
|
| 25 |
+
gr.Number(label="Operating Cost"),
|
| 26 |
+
gr.Number(label="Total Assets"),
|
| 27 |
+
gr.Number(label="Total Liabilities"),
|
| 28 |
+
gr.Number(label="Stock Price"),
|
| 29 |
+
gr.Number(label="Market Cap"),
|
| 30 |
+
gr.Number(label="EBITDA"),
|
| 31 |
+
gr.Number(label="R&D Expenses"),
|
| 32 |
+
gr.Number(label="Number of Employees")
|
| 33 |
+
],
|
| 34 |
+
outputs=gr.Textbox()
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
# Launch the application
|
| 38 |
+
iface.launch()
|