Gotta catch ’em all. The Pokémon Company.

Part -2- of Prediction Pokémon’s rarity,In this project,I have used Pokémon all data from kaggle.The aim for this project is to predict pokémon’s rarity(legendary or common) by using features (for instance; pokémon’s attack,defense,the element that have).And creating a flask app for prediction.I will explain all i did,step by step.You can visit project repository(HERE).The methodology of the project is given below.

You can access Part -1- link HERE

In This Part

  • Create pkl file for our Xgboost model to run with flask app
  • We continue from flask app and add pythonanywhere.com
  1. Create Pkl File

We will use joblib library for creating pkl file.

The codes below are our Xgboost model with parameters that found by bayesian optimization

xg_reg1 = xgb.XGBClassifier(learning_rate = 0.9193,
max_depth= 14,
n_estimators =123,
reg_alpha = 0.988)

And then we have to import joblib,if i dont have install by that code;

!pip install joblib 

import joblib and create pkl file.

import joblib
joblib.dump(xg_reg1,"model7.pkl")
file = open("model7.pkl","wb")
pickle.dump(model7,file)

Now we add prediction for predict our pokémon.

import numpy as np
prediction = model.predict(np.array([[type1,type2,hp,attack,defense,sp_attack,sp_defense,speed,total]]))

total is sum of pokémon’s all stats(attack,defense etc.)

Final part is to add all these codes to flask (link for my github)(for flask codes)

In Flask App ,we have to import numpy and joblib to run our app,the user that access our application(link for my app)give us pokémon’s all stats by using HTML interface.By using that inputs our codes predict our pokémon’s rarity(common or legendary).

2) Create Account and Adding your APP to Cloud(pythonanywhere.com)

In this part,we will add our flask app to cloud by using pythonanywhere.com

we have to sign in pythonywhere.com(HERE).And then we add all our HTML ,CSS,image files and APP codes to cloud.It is DONE!

Our application in Cloud now. :)

Thanks for reading my article.

Hope to see you again in my next article…

Ozan ERTEK

--

--