Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""app.py
|
3 |
-
|
4 |
-
Automatically generated by Colab.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1LNqeNTVe-zMc4YfmFi5S5fPJJcv572lx
|
8 |
-
"""
|
9 |
-
|
10 |
-
import gradio as gr
|
11 |
-
import pickle
|
12 |
-
import numpy as np
|
13 |
-
|
14 |
-
# Load the trained model
|
15 |
-
with open("stock_model.pkl", "rb") as file:
|
16 |
-
model = pickle.load(file)
|
17 |
-
|
18 |
-
# Define the prediction function
|
19 |
-
def predict_stock_price(features):
|
20 |
-
try:
|
21 |
-
# Convert input string to a NumPy array
|
22 |
-
features_array = np.array([float(x) for x in features.split(",")]).reshape(1, -1)
|
23 |
-
# Predict using the model
|
24 |
-
prediction = model.predict(features_array)
|
25 |
-
return f"Predicted Stock Price: {prediction[0]}"
|
26 |
-
except Exception as e:
|
27 |
-
return f"Error: {e}"
|
28 |
-
|
29 |
-
# Create a Gradio Interface
|
30 |
-
interface = gr.Interface(
|
31 |
-
fn=predict_stock_price, # Function to call
|
32 |
-
inputs=gr.Textbox(label="Input Features (comma-separated)", placeholder="1.5, 2.3, 0.7, 5.4"),
|
33 |
-
outputs=gr.Textbox(label="Prediction"),
|
34 |
-
title="Stock Price Predictor",
|
35 |
-
description="Enter features as a comma-separated list to predict stock prices."
|
36 |
-
)
|
37 |
-
|
38 |
-
# Launch the Gradio app
|
39 |
-
if __name__ == "__main__":
|
40 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|