Skip to content

Latest commit

 

History

History
105 lines (67 loc) · 3.52 KB

HowToRun.md

File metadata and controls

105 lines (67 loc) · 3.52 KB

To run the federated learning project for stock prediction using the ARIMA model, you'll need to set up your environment with the necessary dependencies and configure your project correctly. Below are the steps, including the code for installing dependencies and running the project.

1. Project Dependencies

Here’s a list of the required dependencies:

  • Python 3.8+
  • Flask (for the web server and frontend)
  • requests (for HTTP requests between server and clients)
  • pandas (for data manipulation)
  • statsmodels (for ARIMA model)
  • numpy (for numerical operations)

You can install all the dependencies using pip. Create a requirements.txt file:

Flask==2.3.2
requests==2.31.0
pandas==2.0.3
statsmodels==0.14.0
numpy==1.25.1

2. Install Dependencies

To install all the dependencies, navigate to your project directory and run:

pip install -r requirements.txt

This will install all the required Python packages.

3. Running the Server

Navigate to the server directory and run the server:

python server.py

The server will start on http://localhost:5000.

4. Running the Clients

Each client represents a different node in the federated learning setup. You need to run these clients on different machines or separate processes.

Example for Running Client Node 1:

python client_node1.py

Similarly, run client_node2.py and client_node3.py in separate terminals or machines.

5. Running the Frontend

Navigate to the frontend directory and run the Flask app:

python app.py

The frontend will be accessible at http://localhost:5000.

6. Configuring the IP Addresses

In your client_nodeX.py files, make sure to replace server_ip with the actual IP address or hostname of the server where server.py is running. If the server is running on the same machine, you can use localhost.

For example, in client_node1.py:

response = requests.post('http://localhost:5000/send_model', json={"model_params": local_model_params.tolist()})

7. Setting Up the Data

You need to download and place your datasets in the data/ directory.

  • Download the Google Stock Price Dataset from Kaggle.
  • Split the dataset into three parts: stock_data_node1.csv, stock_data_node2.csv, and stock_data_node3.csv.

Each client script will use one of these files to train a local ARIMA model.

8. Running the Full Project

  1. Start the Server: Run server.py in the server directory.
  2. Run the Clients: Run client_node1.py, client_node2.py, and client_node3.py.
  3. Use the Frontend: Navigate to http://localhost:5000 in your web browser.

9. Testing the Application

  • Upload Data: Use the upload interface in the frontend to upload datasets (if not already provided to the clients).
  • Predict: Use the predict interface to trigger predictions and see the results.

10. Troubleshooting

If you encounter any issues:

  • Ensure all dependencies are installed.
  • Check the server and client logs for any errors.
  • Ensure IP addresses are correctly configured.
  • Verify that the datasets are correctly formatted.

This setup should allow you to run the federated learning project for stock prediction using the ARIMA model. The provided code is a starting point and can be extended with additional features like more sophisticated models, secure communication between server and clients, and a more user-friendly frontend.