Skip to content

Instantly share code, notes, and snippets.

# flashtext_regex_timing_keyword_extraction.py
from flashtext.keyword import KeywordProcessor
import random
import string
import re
import time
def get_word_of_length(str_length):
# generate a random word of given length
return ''.join(random.choice(string.ascii_lowercase) for _ in range(str_length))
@skohari
skohari / health.csv
Last active July 11, 2021 08:40
added probabilistic
age sex cp trestbps chol fbs restecg thalach exang oldpeak slope ca thal target age2
63 1 3 145 233 1 0 150 0 2.3 0 0 1 1 0.63
37 1 2 130 250 0 1 187 0 3.5 0 0 2 1 0.37
41 0 1 130 204 0 0 172 0 1.4 2 0 2 1 0.41
56 1 1 120 236 0 1 178 0 0.8 2 0 2 1 0.56
57 0 0 120 354 0 1 163 1 0.6 2 0 2 1 0.57
57 1 0 140 192 0 1 148 0 0.4 1 0 1 1 0.57
56 0 1 140 294 0 0 153 0 1.3 1 0 2 1 0.56
44 1 1 120 263 0 1 173 0 0 2 0 3 1 0.44
52 1 2 172 199 1 1 162 0 0.5 2 0 3 1 0.52
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"age";"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"y"
30;"unemployed";"married";"primary";"no";1787;"no";"no";"cellular";19;"oct";79;1;-1;0;"unknown";"no"
33;"services";"married";"secondary";"no";4789;"yes";"yes";"cellular";11;"may";220;1;339;4;"failure";"no"
35;"management";"single";"tertiary";"no";1350;"yes";"no";"cellular";16;"apr";185;1;330;1;"failure";"no"
30;"management";"married";"tertiary";"no";1476;"yes";"yes";"unknown";3;"jun";199;4;-1;0;"unknown";"no"
59;"blue-collar";"married";"secondary";"no";0;"yes";"no";"unknown";5;"may";226;1;-1;0;"unknown";"no"
35;"management";"single";"tertiary";"no";747;"no";"no";"cellular";23;"feb";141;2;176;3;"failure";"no"
36;"self-employed";"married";"tertiary";"no";307;"yes";"no";"cellular";14;"may";341;1;330;2;"other";"no"
39;"technician";"married";"secondary";"no";147;"yes";"no";"cellular";6;"may";151;2;-1;0;"unknown";"no"
41;"entrepreneur";"married";"tertiary";"no";221;"
@skohari
skohari / reactiveValue.R
Created October 5, 2018 20:43
reactiveValues; for values to be 'floating', and not `fixed`.
ui <- fluidPage(
actionButton("minus", "-1"),
actionButton("plus", "+1"),
br(),
textOutput("value")
)
# The comments below show the equivalent logic using reactiveValues()
server <- function(input, output, session) {
value <- reactiveVal(0) # rv <- reactiveValues(value = 0)
@skohari
skohari / renderUI2.r
Created October 5, 2018 14:27
renderUI2.r
library(shiny)##########################################################################
ui <- fixedPage(
h2("Normal example"),
uiOutput("moreControls"),
uiOutput("moreControls1"),
uiOutput("test")
)
server <- function(input, output, session) {
@skohari
skohari / renderUI.r
Created October 4, 2018 21:53
renderUI as a alternative
library (shiny)
server <- function(input, output) {
rv <- reactiveValues(numFields = 1)
#
# start with one input box
#
output$fieldsUI <- renderUI(textInput("textInput1", "Input #1", 67))
#
@skohari
skohari / eval_parse.R
Last active July 2, 2017 19:53
eval(parse)
t = paste0("head(", "mtcars", ")")
eval(parse(text = t))
# mpg cyl disp hp drat wt qsec vs am gear carb
#Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
#Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
#Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1