Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please define a python class as described below: Constructor : Takes the name of the data file as its only parameter. The constructor will use
Please define a python class as described below:
- Constructor: Takes the name of the data file as its only parameter. The constructor will use Pandas to load the data from the file into a pandas DataFrame. It will then extract the data values form the DataFrame and save it in an instance variable of type numpy array called data.
- A method called stats: This method will use aggregators to find max, min, sum, mean, standrad deviation of each column. The results should be stored in numpy arrays representing each computation. For example, the max array should hold max values of the columns.
- A method called normalize: This method will use broadcasting to normalize each column of the data to the corresponding column's mean and standard deviation. That is, the standard deviation of each column is subtracted from each data point in the column and the result is then divided by the mean of that column. The method should first call the stats methods and then use stats produced to accomplish its tasks. Here is the formula that summarizes what needs to be done:
- A method called plot_data: This method will take as input the following:
- axis: This is the axis for the plot
- feature: This is the feature to be plotted
- normalize: This is a Boolean value indicating if the normalized data (True) or the original data should be plotted. Default should be True.
- A method called save_normalized_data_csv: This method should take as input the name of the output file and then save the normalized data as csv in the corresponding file. HINT: Convert the normalized data to a DataFrame and then save the DataFrame to the file. Bes sure to set index=False when saving the data frame so that the index is not produced to the output file.
- A method called save_normalized_data_pickle: This method should take as input the name of the output file and then save the normalized data in the corresponding file in binary. HINT: Convert the normalized data to a DataFrame and then save the DataFrame to the file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started