Python Forum
Adding a subroutine to a larger program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding a subroutine to a larger program
#1
The following program was written by me. I wanted to plot feature importance against sensor number on a two-dimensional plot. The X axis has the sensor number, and the Y axis has feature importances.

import pandas as pd
import matplotlib.pyplot as plt

# Load the data 
data = pd.read_csv("sensor_data.csv", header=None)

# Extract the feature names and importance values
feature_names = range(0,51)
importances = data[0]

# Plot the data
plt.figure(figsize=(10, 5))
plt.title("Feature Importance")
plt.bar(feature_names, importances)
plt.xlabel("Sensor Index")
plt.ylabel("Importance Value")
plt.show()
Now I want to add this python code to the python program in the attachment, so I have a plot of the data instead of just a vector.

I am not sure how.

Any help appreciated.

R,

Led Zeppelin

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
Adding a subroutine to a larger program - by Led_Zeppelin - Jan-18-2023, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 750 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Adding markers to Folium map only adding last element. tantony 0 2,168 Oct-16-2019, 03:28 PM
Last Post: tantony
  keypad loops/subroutine help arbrunso 1 3,053 Jul-18-2018, 09:39 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020