[PYTHON] Promised victory ("Hobby x Machine Learning")

Introduction

This is the first post. I will write down the material that I have prepared for LT in the company. (I will do my best to continue to output ...)

table of contents

  1. Preface / Purpose
  2. System flow
  3. Details
  4. Announcement of practical results
  5. Conclusion
  6. TODO

1. 1. Preface / Purpose

Title: ** "Hobby x Machine Learning" **

It's a big title, My hobby is ** Pachislot ** ..

What is pachislot?

It is a slot machine installed in pachinko parlors, and is named "rotary type game machine" by law. It is called a pachislot because it is a slot machine in a pachinko parlor. There is a set of ** 6 stages (*) ** in pachislot, which is manually changed by a pachinko clerk after the store is closed.

  • Not all models have 6 levels.

I will explain with a concrete example. "Go Go Juggler KK (Kita Denshi)" image.png (I think many of you know this face.)

The basic specifications of this stand are as follows. image.png

As I explained earlier, there is a setting on the slot base, It is set to approximately ** 6 levels **. And as the setting goes up, the specifications of the machine discount stand also go up.

This setting is ** manually changed by a pachinko parlor clerk every night **.

So I thought.

If you set it manually, Isn't ** law ** born unconsciously ...? image.png

So, the purpose

Collect pachislot data, use machine learning to guide the rules, and be sure to win.

2. System-wide flow

To explain this system insanely about, the composition is as follows. I will explain each step by step. image.png

3. 3. Details

① Data collection

This system is implemented using Python.

environment Windows10 + Anaconda3

** Library used **

-selenium 3.141.0 (crawling) -Beautifulsoup 4.7.1 (scraping)

** Collection period ** 2019/7/15 - 2019/9/14

** Data actually collected **

Year Month Day 曜Day Stand Stand番号 BIG REG Composite probability Cumulative game
2019 7 16 fire Hana Hana Ho-Oh EX-30-2 1353 12 7 1/199.2 3784
2019 7 16 fire Hana Hana Ho-Oh EX-30-2 1355 12 8 1/121.9 2438
2019 7 16 fire Hana Hana Ho-Oh EX-30-2 1356 4 1 1/338.4 1692
2019 7 16 fire Hana Hana Ho-Oh EX-30-2 1357 9 9 1/176.7 3179
2019 7 16 fire Hana Hana Ho-Oh EX-30-2 1358 2 1 1/148.4 445

■ Stumbling point

The site where you can see the pachinko ball output information was only accessible from your smartphone.

Specify the device in the chromedriver option ** Resolve **

mobile_emulation = { "deviceName": "Nexus 5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome("C:/chromedriver.exe", desired_capabilities = chrome_options.to_capabilities())
driver.get("URL of a pachinko parlor")

② Machine learning

Use scikit-learn's "Random Forest".

This time, I stopped the data and learned by expanding the juggler. Predict how many settings the platform will have on that day from the trained model! !!

-** Objective variable : Setting - Explanatory variables **: Date, day of the week

Preprocessing that is not smart at all

#After messing around with the messy dataframe,

#Guess the setting from the probability (it is called the guess value even though it is the objective variable)...)
tmp = line[1][8].split("/")
hoge = float(tmp[0]) / float(tmp[1])
if hoge >= my_pro[5]:
   hoge_np = np.append(hoge_np, 5)
elif hoge >= my_pro[4]:
   hoge_np = np.append(hoge_np, 4)
elif hoge >= my_pro[3]:
   hoge_np = np.append(hoge_np, 3)
elif hoge >= my_pro[2]:
   hoge_np = np.append(hoge_np, 2)
elif hoge >= my_pro[1]:
   hoge_np = np.append(hoge_np, 1)
else:
   hoge_np = np.append(hoge_np, 0)

#There are many other mess...

If you mess with it, throw it into the learning model

#Separate for training and evaluation
x_train, x_test, y_train, y_test = model_selection.train_test_split(x, y, test_size=0.2)

#Learning
model = RandomForestClassifier()
model.fit(x_train, y_train)

③ Practice

■ Practice day 2019/10/5 (Sat)

■ Location A certain pachinko parlor


#### Click here for the fate prediction results! !! !! ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/443963/d14d46a6-96b7-4682-4a4a-b6231c44e941.png)

You can definitely win by hitting the 1257 juggler (setting is 5 !!)! !!

So

image.png

Four. Practical result announcement

When I usually go to hit, I take about three people, Sakichi. I can win this time, so I went to practice with Satoshi! !!

The result is ...! !! !!

image.png



        ↓

image.png

Yes, I was able to bring two Sakichi brilliantly.

Five. Conclusion

Not so sweet.

6.TODO Based on the following points of reflection, we will brush up so that we can definitely win.

Aim for a millionaire! !!


Thank you for staying with us until the end.

Reflections

-The explanatory variables are not plausible. -The settings of the previous day and the settings of the left and right stands should be considered. -You should observe the store trends. -The number of data is not large in the first place. -I don't know if there is a tendency. -Even if you can guess the settings, you cannot always win. ** (Darkness of Pachislot) **

Recommended Posts

Promised victory ("Hobby x Machine Learning")
Machine learning
EV3 x Pyrhon Machine Learning Part 3 Classification
[Memo] Machine learning
Machine learning classification
Machine Learning sample
EV3 x Pyrhon Machine Learning Part 1 Environment Construction
EV3 x Python Machine Learning Part 2 Linear Regression
Machine learning tutorial summary
About machine learning overfitting
Machine learning ⑤ AdaBoost Summary
Machine learning logistic regression
Machine learning support vector machine
Studying Machine Learning ~ matplotlib ~
Machine learning linear regression
Machine learning course memo
Machine learning library dlib
Machine learning (TensorFlow) + Lotto 6
Somehow learn machine learning
Machine learning library Shogun
Machine learning rabbit challenge
Introduction to machine learning
Build a machine learning environment natively on Windows 10 (x64)
Machine Learning: k-Nearest Neighbors
What is machine learning?
Machine learning model considering maintainability
Machine learning learned with Pokemon
Data set for machine learning
Japanese preprocessing for machine learning
Machine learning in Delemas (practice)
An introduction to machine learning
Machine learning / classification related techniques
Basics of Machine Learning (Notes)
Machine learning beginners tried RBM
Machine learning with Python! Preparation
Machine Learning Study Resource Notepad
Machine learning ② Naive Bayes Summary
Understand machine learning ~ ridge regression ~.
Machine learning article summary (self-authored)
About machine learning mixed matrices
Machine Learning: Supervised --Random Forest
Practical machine learning system memo
Machine learning Minesweeper with PyTorch
Machine learning environment construction macbook 2021
Build a machine learning environment
Python Machine Learning Programming> Keywords
Machine learning algorithm (simple perceptron)
Used in machine learning EDA
Importance of machine learning datasets
Machine learning and mathematical optimization
Machine Learning: Supervised --Support Vector Machine
Supervised machine learning (classification / regression)
I implemented Extreme learning machine
Beginning with Python machine learning
Machine learning algorithm (support vector machine)
Super introduction to machine learning
4 [/] Four Arithmetic by Machine Learning
Machine learning ④ K-nearest neighbor Summary
Pokemon machine learning Nth decoction
Try machine learning with Kaggle
Machine learning stacking template (regression)