Skip to content

Instantly share code, notes, and snippets.

@foohm71
foohm71 / txt-setup.py
Created Jan 7, 2021
text similarity setup
View txt-setup.py
from google.colab import drive
drive.mount('/content/gdrive')
import gensim
from gensim.models import KeyedVectors
import numpy as np
import pandas as pd
import nltk
from nltk import word_tokenize
@foohm71
foohm71 / functions.py
Created Sep 12, 2020
Common functions
View functions.py
def make_autopct(values):
def my_autopct(pct):
total = sum(values)
val = int(round(pct*total/100.0))
return '{p:.1f}% ({v:d})'.format(p=pct,v=val)
return my_autopct
def plotPieChart(column):
freq_count = Counter(df[column])
fig, ax = plt.subplots(figsize=(15, 7), subplot_kw=dict(aspect="equal"))
@foohm71
foohm71 / main.py
Created Sep 12, 2020
Imports for survey results
View main.py
import pandas as pd
import matplotlib.pylab as plt
import numpy as np
from collections import Counter
from wordcloud import WordCloud, STOPWORDS
from gensim.summarization.summarizer import summarize
from gensim.summarization import keywords
from IPython.display import display, Markdown
View evaluate.py
from sklearn.metrics import confusion_matrix
import matplotlib.pylab as plt
# Train/Test split was done earlier hence I just need to use Xtest and Ytest
result = []
for feature in Xtest:
p = get_prediction(feature, model_name)
result.append(p.payload[0].display_name)
labels = ['Optional', 'Trivial', 'Minor', 'Major', 'Critical', 'Blocker']
@foohm71
foohm71 / convert.py
Created Jul 27, 2020
AutoML conversion
View convert.py
# write training data function
def write_training_data_to_zipfile(path, Xdata, Ydata):
os.chdir(path)
count = {}
num_rows = Xdata.shape[0]
for i in range(1,num_rows):
label = Ydata.iloc[i]
feature = Xdata.iloc[i]
folder = path + "/" + label
if not os.path.exists(folder):
@foohm71
foohm71 / main.py
Created Jul 27, 2020
AppEngine code
View main.py
# [START gae_python38_app]
from flask import Flask, request
import sys
import os
from google.api_core.client_options import ClientOptions
from google.cloud import automl_v1
from google.cloud.automl_v1.proto import service_pb2
# If `entrypoint` is not defined in app.yaml, App Engine will look for an app
# called `app` in `main.py`.