Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the following code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import torch import torch.utils.data as data_utils !gdown --id 1r8c6Qv3BiU_LNMSrvtex00lFbrut-Fnx

Using the following code:

import pandas as pd import numpy as np import matplotlib.pyplot as plt import torch import torch.utils.data as data_utils

!gdown --id 1r8c6Qv3BiU_LNMSrvtex00lFbrut-Fnx df = pd.read_csv('emg_features.csv', header=None)

nClasses=7 header = [] for f in range(10): for i in range(8): header.append('c_'+str(f)+'_'+str(i)) header.append('label') df.columns = header pd.options.mode.use_inf_as_na = True print(df.isnull().values.any()) print(len(df))

fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(20,16)) for feature in range(10): line =int(feature/3) column = int(feature%3) axes[line,column].hist(df.iloc[:,feature*8:-1+(feature+1)*8].values.reshape(-1),bins=20) axes[line,column].set_title('Feature ' + str(feature)) (df['label']).plot(kind='hist',bins=nClasses)

# Adjust so that they all fit between [0;1] or [-1;1] using min-max normalization, (df-df.mean())/(df.max()-df.min()) # The last column is the output and should not be normalized. However, their values are in the range [1;7] Pytorch expects outputs starting at 0, for classification is necessary

from sklearn import datasets from sklearn.preprocessing import StandardScaler

# After applying StandardScaler(), each column in X will have mean of 0 and standard deviation of 1 df = StandardScaler()

XTrain = scaleX.fit_transform(XTrain) XTest = scaleX.fit_transform(XTest)

adjusted_df = (df-df.mean())/(df.max()-df.min())

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions