rachmaninoffpk / tensorflow-pokemon-course Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://lab.github.com/everydeveloper/advance-tensorflow
Home Page: https://lab.github.com/everydeveloper/advance-tensorflow
Now that we have our data in a useable form, we need to split it. We want to have a set of data that we'll use to train our model, and we'll use another set of data to test our model after we've trained it. In general, the data is randomly split with about 70% being used for training and 30% used for testing. For easier visualization, we'll be splitting the data by Pokémon generation. The first generation of Pokémon (from Pokémon Red, Blue, and Yellow) will be our testing data while the rest will be our training data:
def train_test_splitter(DataFrame, column):
df_train = DataFrame.loc[df[column] != 1]
df_test = DataFrame.loc[df[column] == 1]
df_train = df_train.drop(column, axis=1)
df_test = df_test.drop(column, axis=1)
return(df_train, df_test)
df_train, df_test = train_test_splitter(df, 'Generation')
This function takes any Pokémon whose "Generation" label is equal to 1 and putting it into the test dataset, and putting everyone else in the training dataset. It then drop
s the Generation
category from the dataset.
Now that we have our two sets of data, we'll need to separate the labels (the 'islegendary' category) from the rest of the data. Remember, this is the answer key to the test the algorithms are trying to solve, and it does no good to have them learn with the answer-key in (metaphorical) hand:
def label_delineator(df_train, df_test, label):
train_data = df_train.drop(label, axis=1).values
train_labels = df_train[label].values
test_data = df_test.drop(label,axis=1).values
test_labels = df_test[label].values
return(train_data, train_labels, test_data, test_labels)
This function extracts the data from the DataFrame and puts it into arrays that TensorFlow can understand with.values
. We then have the four groups of data:
train_data, train_labels, test_data, test_labels = label_delineator(df_train, df_test, 'isLegendary')
Comment with the generation number we used in the test dataset.
Welcome to the world of machine learning with TensorFlow! Working with TensorFlow can seem intimidating at first, but this tutorial will start with the basics to ensure you have a strong foundation with the package. This tutorial will be focusing on classifying and predicting Pokémon, but the elements discussed within it can certainly be helpful when using TensorFlow for other ideas, as well. Without further ado, let's begin!
First, let's download TensorFlow through pip
. While you can install the version of TensorFlow that uses your GPU, we'll be using the CPU-driven TensorFlow. Type this into your terminal:
pip install tensorflow
Now that it's installed, we can truly begin. Let's import Tensorflow, and a few other packages we'll need. All of this course involve using the command line interface. Enter these commands to import and the necessary packages:
import tensorflow as tf
from tensorflow import keras
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import preprocessing
Leave a comment with your favorite Pokémon (such as Pikachu) to continue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.