Skip to content

Instantly share code, notes, and snippets.

View minesh1291's full-sized avatar
๐Ÿš–
On The Journey to Neverland

Minesh A. Jethva minesh1291

๐Ÿš–
On The Journey to Neverland
View GitHub Profile
@minesh1291
minesh1291 / reproducible.md
Created May 21, 2020 11:35 — forked from hadley/reproducible.md
How to write a reproducible example

How to write a reproducible example.

You are most likely to get good help with your R problem if you provide a reproducible example. A reproducible example allows someone else to recreate your problem by just copying and pasting R code.

There are four things you need to include to make your example reproducible: required packages, data, code, and a description of your R environment.

  • Packages should be loaded at the top of the script, so it's easy to see which ones the example needs.

  • The easiest way to include data in an email is to use dput() to generate

"""
A weighted version of categorical_crossentropy for keras (2.0.6). This lets you apply a weight to unbalanced classes.
@url: https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d
@author: wassname
"""
from keras import backend as K
def weighted_categorical_crossentropy(weights):
"""
A weighted version of keras.objectives.categorical_crossentropy
import nltk
import gensim
text = requests.get('http://rare-technologies.com/the_matrix_synopsis.txt').text
gensim_summary = gensim.summarization.summarize(text)
"""
First install text_summarizer using
pip install git+https://github.com/lambdaofgod/text-summarizer
"""
import nltk
import text_summarizer
# prepare nltk data
nltk.download('punkt')
@minesh1291
minesh1291 / Text-summarization.py
Created June 2, 2020 15:12 — forked from edubey/Text-summarization.py
Text Summarizer in Python
#!/usr/bin/env python
# coding: utf-8
from nltk.corpus import stopwords
from nltk.cluster.util import cosine_distance
import numpy as np
import networkx as nx
def read_article(file_name):
file = open(file_name, "r")
@minesh1291
minesh1291 / 1_notmnist.ipynb
Created June 6, 2020 13:02 — forked from ivikash/1_notmnist.ipynb
UD 730 - Udacity Introduction to deep learning
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from allennlp.predictors.predictor import Predictor as AllenNLPPredictor
class Predictor:
def __init__(self, config):
self.predictor = AllenNLPPredictor.from_path(
"https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2018.11.30-charpad.tar.gz"
)
def predict(self, payload):
prediction = self.predictor.predict(
class XGBQuantile(XGBRegressor):
def __init__(self,quant_alpha=0.95,quant_delta = 1.0,quant_thres=1.0,quant_var =1.0,base_score=0.5, booster='gbtree', colsample_bylevel=1,
colsample_bytree=1, gamma=0, learning_rate=0.1, max_delta_step=0,max_depth=3, min_child_weight=1, missing=None, n_estimators=100,
n_jobs=1, nthread=None, objective='reg:linear', random_state=0,reg_alpha=0, reg_lambda=1, scale_pos_weight=1, seed=None,silent=True, subsample=1):
self.quant_alpha = quant_alpha
self.quant_delta = quant_delta
self.quant_thres = quant_thres
self.quant_var = quant_var
super().__init__(base_score=base_score, booster=booster, colsample_bylevel=colsample_bylevel,
# My version of the code at this blog post:
# https://towardsdatascience.com/automl-a-tool-to-improve-your-workflow-1a132248371f
import h2o
from h2o.automl import H2OAutoML
h2o.init()
train = h2o.import_file("https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data")
y = "C1" #e = edible, p = poisonous