Model Training and Evaluation

As this is a Classification problem then we will be using the below models for training the data.

And for evaluation, we will be using Accuracy Score.

Python3




from sklearn.neighbors import KNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from sklearn.linear_model import LogisticRegression
  
from sklearn import metrics
  
knn = KNeighborsClassifier(n_neighbors=3)
rfc = RandomForestClassifier(n_estimators = 7,
                             criterion = 'entropy',
                             random_state =7)
svc = SVC()
lc = LogisticRegression()
  
# making predictions on the training set
for clf in (rfc, knn, svc,lc):
    clf.fit(x_train, y_train)
    y_pred = clf.predict(x_test)
    print("Accuracy score of ",clf.__class__.__name__,"=",
          100*metrics.accuracy_score(y_test, y_pred))


Output : 

Accuracy score of  RandomForestClassifier = 84.5
Accuracy score of  KNeighborsClassifier = 82.5
Accuracy score of  SVC = 86.15
Accuracy score of  LogisticRegression = 80.75

Data Preprocessing, Analysis, and Visualization for building a Machine learning model

In this article, we are going to see the concept of Data Preprocessing, Analysis, and Visualization for building a Machine learning model. Business owners and organizations use Machine Learning models to predict their Business growth. But before applying machine learning models, the dataset needs to be preprocessed.

So, let’s import the data and start exploring it.

Similar Reads

Importing Libraries and Dataset

We will be using these libraries :...

Exploratory data analysis and visualization

...

Data Preprocessing

...

Model Training and Evaluation

...

Conclusion

To find out the correlation between the features, Let’s make the heatmap....

Contact Us