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
brew update | |
brew tap adoptopenjdk/openjdk | |
brew search jdk | |
brew cask install adoptopenjdk11 | |
brew cask install adoptopenjdk12 | |
brew cask install adoptopenjdk13 | |
# Check where Java is installed | |
/usr/libexec/java_home -V | |
Change Versions |
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
def namedtuple_to_str(t, field_widths=15): | |
if isinstance(field_widths, int): | |
field_widths = [field_widths] * len(t._fields) | |
field_pairs = ['{}={}'.format(field, getattr(t, field)) for field in t._fields] | |
s = ' '.join('{{:{}}}'.format(w).format(f) for w,f in zip(field_widths, field_pairs)) | |
result = '{}( {} )'.format(type(t).__name__, s) | |
return result |
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
#Code snippets for Pandas | |
import pandas as pd | |
‘’’ | |
Reading Files, Selecting Columns, and Summarizing | |
‘’’ | |
# reading in a file from local computer or directly from a URL | |
# various file formats that can be read in out wrote out | |
‘’’ | |
Format Type Data Description Reader Writer | |
text CSV read_csv to_csv |
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
__author__='satish' | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import plotly as ply | |
from sklearn.feature_extraction.text import CountVectorizer,HashingVectorizer | |
from sklearn.cross_validation import train_test_split | |
from sklearn.naive_bayes import BernoulliNB | |
from sklearn.naive_bayes import MultinomialNB,GaussianNB | |
from sklearn.linear_model import LogisticRegression,RidgeClassifier,Perceptron,PassiveAggressiveClassifier |
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 wordcloud import WordCloud | |
wordcloud = WordCloud().generate(text) | |
# Display the generated image: | |
# the matplotlib way: | |
import matplotlib.pyplot as plt | |
plt.imshow(wordcloud) | |
plt.axis("off") | |
# take relative word frequencies into account, lower max_font_size | |
wordcloud = WordCloud(max_font_size=40, relative_scaling=.5).generate(text) | |
plt.figure() |
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
""" | |
Reads Google search history JSON files from the given directory. | |
Expected JSON format : | |
{"event":[ | |
{"query":{"id":[{"timestamp_usec":"1135905619017279"}],"query_text":"XYZ"}}, | |
{"query":{"id":[{"timestamp_usec":"1135903586447380"}],"query_text":"ABC"}}, | |
]} | |
The folder containing the JSON files is stored in a config.ini file with the section |
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
cuisine ingredients | |
cuisine_group | |
African 0.637300 0.637300 | |
EastAsian 3.231764 3.231764 | |
EasternEuropean 0.689805 0.689805 | |
LatinAmerican 5.255916 5.255916 | |
MiddleEastern 1.167780 1.167780 | |
NorthAmerican 75.179693 75.179693 | |
NorthernEuropean 0.452628 0.452628 | |
SouthAsian 1.124328 1.124328 |
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
def clean_data(filenames): | |
dfs=[] | |
for filename in filenames: | |
epic_df = pd.read_csv(filename,names=['col'],header=None) | |
epic_df['cuisine']=epic_df['col'].apply(lambda x : x.split('\t')[0]) | |
epic_df['ingredients'] = epic_df['col'].apply(lambda x:(',').join (x.split('\t')[1:])) | |
epic_df.drop('col',inplace=True,axis=1) | |
dfs.append(epic_df) | |
return dfs |