<jupyter_start><jupyter_text><jupyter_code># read in dataset 1: pokemon Go character sightings

import pandas as pd

df = pd.read_csv('300k.csv')
pd.set_option("display.max_rows", 91835)
#pd.set_option("display.max_columns", 300)
df

# read in dataset 2: encoded names and corresponding id#s
df_Names = pd.read_csv('pokemonNumbers.csv', header= None)
pd.set_option("display.max_rows", 91835)
df_Names
#EXPLORATORY DATA ANALYSIS/DATA WRANGLING

# change df_Names column names
df_Names.columns=['pokeID_num_From_df_Names', 'pokemonName']
df_Names
# check df_Names column datatypes
print(df_Names.dtypes)
# join df and df_Names using .concat for union of dfs - WORKS but GET NaNs
'''
df3 =  pd.concat([df_Names, df], axis=1, sort=False)
pd.set_option("display.max_rows", 91835)
df3
'''
# merge df and df_Names using -NOT WORK
# df_Names.merge(df, left_on='pokemonName', right_on='pokemonId')
# MATCH or REPLACE pokemonId with pokemonName

# 1. convert df_Names into a dictionary
# check Nulls- returns 0 for all columns
df.isnull().sum()

df.columns
#Get BASELINE- the first way to get the highest accuracy by assuming majority, [by] assum[ing] majority:

pd.set_option('display.max_columns', 500)
pd.set_option('display.max_row', 300000)
'''
average for regression should be the majority value in a sense; 
classification is assuming all values are the highest majority value- BASELINE IS PREDICTING MODE CLASS (largest # of observations
'''
df.value_counts
# Fit a Classification model
# Try a shallow decision tree as a fast, first model

#pip install --upgrade category_encoders
# from sklearn.preprocessing import CategoricalEncoder
#pip install category_encoders

!pip install category_encoders==2.* 

import numpy as np
import category_encoders as ce
from sklearn.pipeline import make_pipeline
from sklearn.impute import SimpleImputer
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split

#encoder = ce.OrdinalEncoder(cols=[...])

target = 'appearedDayOfWeek'
features = ['appearedMonth', 'appearedYear', 'appearedDay', 'pokestopDistanceKm', 'weather', 'latitude', 'longitude']

#train = df 

X_train, X_test, y_train, y_test = train_test_split(df[features], df[target])
#train, test = train_test_split(df)

pipeline = make_pipeline(
    ce.OrdinalEncoder(),
    SimpleImputer(strategy='most_frequent'),
    RandomForestClassifier()
)

pipeline.fit(X_train, y_train)
acc_score = pipeline.score(test[features], test[target])
ra_score = roc_auc_score(test[target], pipeline.predict(test[features]))

print(f'Test Accuracy: {pipeline.score(X_test, y_test)}')
print(f'Test ROC AUC: {roc_auc_score(y_test, pipeline.predict(X_test))}\n')

print(f'Val Accuracy: {acc_score}')
print(f'Val ROC AUC: {ra_score}')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10701876302988186, 'fraction_numerical': 0.01320361362056984, 'mean_word_length': 6.477922077922078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '56225', 'license': 'MIT', 'n_tokens_mistral': 1019, 'n_tokens_neox': 971, 'n_words': 267, 'path': 'new_Fri_Mar_6_build_2.ipynb', 'repo_name': 'LambdaTheda/DS-Unit-2-Linear-Models', 'size': '2878'}