commit 8c0c0b9d7815b99378e4de2eedf32ad349f7f55b Author: amirmoghi3 Date: Thu Dec 31 20:19:52 2020 +0330 Initial Commit diff --git a/.history/app_20201231195755.py b/.history/app_20201231195755.py new file mode 100644 index 0000000..e69de29 diff --git a/.history/app_20201231200318.py b/.history/app_20201231200318.py new file mode 100644 index 0000000..0377641 --- /dev/null +++ b/.history/app_20201231200318.py @@ -0,0 +1,103 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.cross_validation import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + balance_data = pd.read_excel('Train.xlsx', sheet_name="Sheet1").to_numpy() + + # Printing the dataswet shape + print ("Dataset Length: ", len(balance_data)) + print ("Dataset Shape: ", balance_data.shape) + + # Printing the dataset obseravtions + print ("Dataset: ",balance_data.head()) + return balance_data + +# Function to split the dataset +def splitdataset(balance_data): + + # Separating the target variable + X = balance_data.values[:, 1:5] + Y = balance_data.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.history/app_20201231201128.py b/.history/app_20201231201128.py new file mode 100644 index 0000000..735243c --- /dev/null +++ b/.history/app_20201231201128.py @@ -0,0 +1,103 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + balance_data = pd.read_excel('Train.xlsx', sheet_name="Sheet1").to_numpy() + + # Printing the dataswet shape + print ("Dataset Length: ", len(balance_data)) + print ("Dataset Shape: ", balance_data.shape) + + # Printing the dataset obseravtions + print ("Dataset: ",balance_data.head()) + return balance_data + +# Function to split the dataset +def splitdataset(balance_data): + + # Separating the target variable + X = balance_data.values[:, 1:5] + Y = balance_data.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.history/app_20201231201209.py b/.history/app_20201231201209.py new file mode 100644 index 0000000..c5ce610 --- /dev/null +++ b/.history/app_20201231201209.py @@ -0,0 +1,96 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + balance_data = pd.read_excel('Train.xlsx', sheet_name="Sheet1").to_numpy() + return balance_data + +# Function to split the dataset +def splitdataset(balance_data): + + # Separating the target variable + X = balance_data.values[:, 1:5] + Y = balance_data.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.history/app_20201231201258.py b/.history/app_20201231201258.py new file mode 100644 index 0000000..011819d --- /dev/null +++ b/.history/app_20201231201258.py @@ -0,0 +1,96 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + dataset = pd.read_excel('Train.xlsx', sheet_name="Sheet1").to_numpy() + return dataset + +# Function to split the dataset +def splitdataset(dataset): + + # Separating the target variable + X = dataset.values[:, 1:5] + Y = dataset.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.history/app_20201231201711.py b/.history/app_20201231201711.py new file mode 100644 index 0000000..93e927b --- /dev/null +++ b/.history/app_20201231201711.py @@ -0,0 +1,96 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + balance_data = pd.read_csv( 'Train.csv',sep= ',', header = None) + return dataset + +# Function to split the dataset +def splitdataset(dataset): + + # Separating the target variable + X = dataset.values[:, 1:5] + Y = dataset.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.history/app_20201231201714.py b/.history/app_20201231201714.py new file mode 100644 index 0000000..dadd4e6 --- /dev/null +++ b/.history/app_20201231201714.py @@ -0,0 +1,96 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + dataset = pd.read_csv( 'Train.csv',sep= ',', header = None) + return dataset + +# Function to split the dataset +def splitdataset(dataset): + + # Separating the target variable + X = dataset.values[:, 1:5] + Y = dataset.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c8a63ca --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe" +} \ No newline at end of file diff --git a/Train.csv b/Train.csv new file mode 100644 index 0000000..d5952af --- /dev/null +++ b/Train.csv @@ -0,0 +1,300 @@ +-1,1,-1,1,1,1,-1,-1,-1,1,0,1,1,1,-1,1,1 +-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,0,1 +0,1,1,0,1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,2 +-1,1,1,-1,0,1,-1,-1,-1,-1,1,-1,1,-1,-1,1,2 +1,1,1,-1,1,1,-1,-1,-1,-1,1,0,1,1,1,1,2 +-1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,2 +-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,0,1,1,1,2 +-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,1,1 +-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,1,1 +1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,0,0,2 +-1,1,-1,1,1,-1,-1,-1,-1,-1,0,0,1,1,-1,-1,1 +-1,1,-1,1,1,1,-1,-1,-1,-1,1,0,1,1,0,0,1 +-1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,0,0,2 +1,1,1,-1,-1,1,1,1,0,1,1,0,-1,-1,1,0,2 +-1,1,-1,1,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-1,1 +-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,2 +1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,-1,0,1 +1,-1,-1,1,1,1,-1,-1,-1,1,-1,0,1,1,-1,-1,1 +-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,1,1 +-1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,0,1,2 +-1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,1,1,2 +-1,-1,1,-1,-1,1,0,1,0,1,1,1,-1,1,1,0,2 +1,1,1,0,-1,1,1,1,1,-1,1,-1,1,-1,0,1,2 +1,1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,2 +1,1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,-1,0,2 +1,-1,1,-1,0,1,0,1,1,1,-1,-1,1,1,-1,1,2 +1,-1,1,-1,-1,1,1,1,1,1,-1,0,-1,1,-1,1,2 +1,-1,1,-1,-1,1,1,1,-1,1,1,-1,1,1,1,1,2 +1,1,1,-1,-1,1,1,1,1,1,1,-1,1,1,1,1,2 +-1,1,1,-1,-1,1,1,1,-1,1,1,-1,1,1,-1,0,2 +-1,1,-1,1,1,1,0,0,-1,1,-1,1,0,0,0,0,1 +-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,1,1 +1,1,1,-1,-1,1,1,1,1,1,-1,-1,0,-1,1,0,2 +-1,1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,1,2 +-1,1,1,-1,-1,1,1,1,1,1,-1,-1,1,1,1,1,2 diff --git a/Train.xlsx b/Train.xlsx new file mode 100644 index 0000000..02158b7 Binary files /dev/null and b/Train.xlsx differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..dadd4e6 --- /dev/null +++ b/app.py @@ -0,0 +1,96 @@ +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from sklearn.model_selection import train_test_split +from sklearn.tree import DecisionTreeClassifier +from sklearn.metrics import accuracy_score +from sklearn.metrics import classification_report + +# Function importing Dataset +def importdata(): + dataset = pd.read_csv( 'Train.csv',sep= ',', header = None) + return dataset + +# Function to split the dataset +def splitdataset(dataset): + + # Separating the target variable + X = dataset.values[:, 1:5] + Y = dataset.values[:, 0] + + # Splitting the dataset into train and test + X_train, X_test, y_train, y_test = train_test_split( + X, Y, test_size = 0.3, random_state = 100) + + return X, Y, X_train, X_test, y_train, y_test + +# Function to perform training with giniIndex. +def train_using_gini(X_train, X_test, y_train): + + # Creating the classifier object + clf_gini = DecisionTreeClassifier(criterion = "gini", + random_state = 100,max_depth=3, min_samples_leaf=5) + + # Performing training + clf_gini.fit(X_train, y_train) + return clf_gini + +# Function to perform training with entropy. +def tarin_using_entropy(X_train, X_test, y_train): + + # Decision tree with entropy + clf_entropy = DecisionTreeClassifier( + criterion = "entropy", random_state = 100, + max_depth = 3, min_samples_leaf = 5) + + # Performing training + clf_entropy.fit(X_train, y_train) + return clf_entropy + + +# Function to make predictions +def prediction(X_test, clf_object): + + # Predicton on test with giniIndex + y_pred = clf_object.predict(X_test) + print("Predicted values:") + print(y_pred) + return y_pred + +# Function to calculate accuracy +def cal_accuracy(y_test, y_pred): + + print("Confusion Matrix: ", + confusion_matrix(y_test, y_pred)) + + print ("Accuracy : ", + accuracy_score(y_test,y_pred)*100) + + print("Report : ", + classification_report(y_test, y_pred)) + +# Driver code +def main(): + + # Building Phase + data = importdata() + X, Y, X_train, X_test, y_train, y_test = splitdataset(data) + clf_gini = train_using_gini(X_train, X_test, y_train) + clf_entropy = tarin_using_entropy(X_train, X_test, y_train) + + # Operational Phase + print("Results Using Gini Index:") + + # Prediction using gini + y_pred_gini = prediction(X_test, clf_gini) + cal_accuracy(y_test, y_pred_gini) + + print("Results Using Entropy:") + # Prediction using entropy + y_pred_entropy = prediction(X_test, clf_entropy) + cal_accuracy(y_test, y_pred_entropy) + + +# Calling main function +if __name__=="__main__": + main() \ No newline at end of file