This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
#By default this will use all the cpu cores on your machine by splitting the corpus (or selected list) into n pieces and | |
#will run the function specified in the first argument | |
with mp.Pool() as pool: | |
str_business_df['nltk_dict'] = pool.map(nlp.vectorize, str_business_df['corp']) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
import nltk | |
import string | |
import re | |
from nltk.corpus import stopwords | |
import pandas as pd | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.metrics.pairwise import linear_kernel | |
stop = stopwords.words('english') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#AWS credential setup | |
# pip install awscli | |
# pip install boto3 | |
# aws configure | |
# Configure guide: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html | |
##Configure-QuickConfigure-IAMconsole-DeleteYourRootAccessKeys-ManageSecurityCredentials-AccessKeys-CreateNewKey | |
import boto3 | |
s3 = boto3.resource('s3') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pandas as pd | |
from glob import glob | |
import matplotlib.pyplot as plt | |
#Convert json string to a flat python dictionary | |
def convert(x): | |
ob = json.loads(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class House(): | |
def __init__(self, train_data_file, test_data_file): | |
train = pd.read_csv(train_data_file) | |
test = pd.read_csv(test_data_file) | |
self.all = pd.concat([train,test], ignore_index=True) | |
self.all['test'] = self.all.SalePrice.isnull() | |
def train(self): | |
return(self.all[~self.all['test']]) |