Hyperparameter Optimization or tuning is the problem of choosing a set of optimal hyperparameters for a learning algorithm. The same kind of machine learning model can require different constraints, weights or learning rates to generalize different data patterns. These measures are called hyperparameters, and have to be tuned so that the model can optimally solve the machine learning problem. Hyperparameter optimization finds a tuple of hyperparameters that yields an optimal model which minimizes a predefined
loss function on given independent data.
Training Data Set
The training data set is the actual dataset used to train the model for performing various Machine Learning Operations (Regression, Classification, Clustering etc.). This is the actual data with which the models learn with various API and algorithm to train the machine to work automatically
Test Data Set
Test data set helps you to validate that the training has happened efficiently in terms of either accuracy, or precision so on. Actually, such data is used for testing the model whether it is responding or working appropriately or not.
Hyperparameter Tuning Code Block Before Tuning
# Hyperparameter Tuning
if vAR_Fetched_Data_Hyperparameter_Tuning_Required =='Y':
import matplotlib.pyplot as vAR_plt
vAR_le = LabelEncoder()
vAR_Transaction_Type_Conversion = vAR_le.fit_transform(vAR_df.iloc[:,7])
vAR_Transaction_Type_Conversion_df = vAR_pd.DataFrame(vAR_Transaction_Type_Conversion,columns={'Transaction_Type_Converted'})
vAR_Data_Category_Conversion = vAR_le.fit_transform(vAR_df.iloc[:,9])
vAR_Data_Category_Conversion_df = vAR_pd.DataFrame(vAR_Data_Category_Conversion,columns={'Data_Category_Converted'})
vAR_Features_train = vAR_pd.read_excel(vAR_Fetched_Data_Train_All_Features)
vAR_Label_train = vAR_df.iloc[:,12]
vAR_model = LogisticRegression()
vAR_model.fit(vAR_Features_train,vAR_Label_train)
vAR_plt.scatter(vAR_Features_train.iloc[:,0],vAR_Label_train,s=100, c='gbc')
vAR_df3 = vAR_pd.read_excel(vAR_Fetched_Data_Source_Path_Test_Data)
vAR_Transaction_Type_Conversion_test = vAR_le.fit_transform(vAR_df3.iloc[:,3])
vAR_Transaction_Type_Conversion_test_df = vAR_pd.DataFrame(vAR_Transaction_Type_Conversion_test,columns={'Transaction_Type_Converted'})
vAR_Data_Category_Conversion_test = vAR_le.fit_transform(vAR_df.iloc[:,4])
vAR_Data_Category_Conversion_test_df = vAR_pd.DataFrame(vAR_Data_Category_Conversion_test,columns={'Data_Category_Converted'})
vAR_df4 = vAR_df3.merge(vAR_Transaction_Type_Conversion_test_df,left_index=True, right_index=True)
vAR_df5 = vAR_df4.merge(vAR_Data_Category_Conversion_test_df,left_index=True, right_index=True)
vAR_Features_test = vAR_pd.read_excel(vAR_Fetched_Data_Test_All_Features)
vAR_Labels_Pred = vAR_model.predict(vAR_Features_test)
vAR_Labels_Pred = vAR_pd.DataFrame(vAR_Labels_Pred,columns={'Predicted_Inter_Transaction_Type'})
vAR_df6 = vAR_pd.read_excel(vAR_Fetched_Data_Source_Path_Test_Data)
vAR_df7 = vAR_df6.merge(vAR_Labels_Pred,left_index=True, right_index=True)
vAR_df8 = vAR_df7.to_excel(vAR_Fetched_Data_Model_Path, engine='xlsxwriter')
vAR_df9 = vAR_pd.read_excel(vAR_Fetched_Data_Model_Path)
vAR_plt.plot(vAR_df9.iloc[:,0],vAR_df9.iloc[:,5],c='b') vAR_plt.xlabel('Company')
vAR_plt.ylabel('Predicted Intercompany Transaction')
vAR_plt.savefig(vAR_Fetched_Data_Before_Hyperparameter_Tuning_Image)
Hyperparameter Tuning Plotted Before Tuning
Training Data Set
The training data set is the actual dataset used to train the model for performing various Machine Learning Operations (Regression, Classification, Clustering etc.). This is the actual data with which the models learn with various API and algorithm to train the machine to work automatically
Test Data Set
Test data set helps you to validate that the training has happened efficiently in terms of either accuracy, or precision so on. Actually, such data is used for testing the model whether it is responding or working appropriately or not.
Hyperparameter Tuning Code Block After Tuning
if Fetched_Data_Hyperparameter_Tuning_Required =='Y':
import matplotlib.pyplot as vAR_plt
vAR_le = LabelEncoder()
vAR_Transaction_Type_Conversion = vAR_le.fit_transform(vAR_df.iloc[:,7])
vAR_Transaction_Type_Conversion_df = vAR_pd.DataFrame(vAR_Transaction_Type_Conversion,columns={'Transaction_Type_Converted'})
vAR_Data_Category_Conversion = vAR_le.fit_transform(vAR_df.iloc[:,9])
vAR_Data_Category_Conversion_df = vAR_pd.DataFrame(vAR_Data_Category_Conversion,columns={'Data_Category_Converted'})
vAR_Features_train = vAR_pd.read_excel(Fetched_Data_Train_All_Features)
vAR_Label_train = vAR_df.iloc[:,12]
vAR_model = LogisticRegression(C=10.0, fit_intercept=False, warm_start=True)
vAR_model.fit(vAR_Features_train,vAR_Label_train)
vAR_plt.scatter(vAR_Features_train.iloc[:,0],vAR_Label_train,s=100, c='gbc')
vAR_df3 = vAR_pd.read_excel(vAR_Fetched_Data_Source_Path_Test_Data)
vAR_Transaction_Type_Conversion_test = vAR_le.fit_transform(vAR_df3.iloc[:,3])
vAR_Transaction_Type_Conversion_test_df = vAR_pd.DataFrame(vAR_Transaction_Type_Conversion_test,columns={'Transaction_Type_Converted'})
vAR_Data_Category_Conversion_test = vAR_le.fit_transform(vAR_df.iloc[:,4])
vAR_Data_Category_Conversion_test_df = vAR_pd.DataFrame(vAR_Data_Category_Conversion_test,columns={'Data_Category_Converted'})
vAR_df4 = vAR_df3.merge(vAR_Transaction_Type_Conversion_test_df,left_index=True, right_index=True)
vAR_df5 = vAR_df4.merge(vAR_Data_Category_Conversion_test_df,left_index=True, right_index=True)
vAR_Features_test = vAR_pd.read_excel(Fetched_Data_Test_All_Features)
vAR_Labels_Pred = vAR_model.predict(vAR_Features_test)
vAR_Labels_Pred = vAR_pd.DataFrame(vAR_Labels_Pred,columns={'Predicted_Inter_Transaction_Type'})
vAR_df6 = vAR_pd.read_excel(vAR_Fetched_Data_Source_Path_Test_Data)
vAR_df7 = vAR_df6.merge(vAR_Labels_Pred,left_index=True, right_index=True)
vAR_df8 = vAR_df7.to_excel(vAR_Fetched_Data_Model_Path, engine='xlsxwriter')
vAR_df9 = vAR_pd.read_excel(vAR_Fetched_Data_Model_Path)
vAR_plt.plot(vAR_df9.iloc[:,0],vAR_df9.iloc[:,5],c='b')
vAR_plt.xlabel('Company')
vAR_plt.ylabel('Predicted Intercompany Transaction')
#vAR_plt.show()
vAR_plt.savefig(vAR_Fetched_Data_After_Hyperparameter_Tuning_Image)
Hyperparameter Tuning Plotted After Tuning
Content Developer
Our team is comprised of MIT learning facilitators, Harvard PhDs, Stanford alumni, leading management consulting experts, industry leaders and proven entrepreneurs. Collectively, our team brings business and technology together with risk-free implementation of artificial intelligence for enterprise.