Skip to content

Instantly share code, notes, and snippets.

TRAIN_DATA =[ ("Pizza is a common fast food.", {"entities": [(0, 5, "FOOD")]}),
("Pasta is an italian recipe", {"entities": [(0, 5, "FOOD")]}),
("China's noodles are very famous", {"entities": [(8,14, "FOOD")]}),
("Shrimps are famous in China too", {"entities": [(0,7, "FOOD")]}),
("Lasagna is another classic of Italy", {"entities": [(0,7, "FOOD")]}),
("Sushi is extemely famous and expensive Japanese dish", {"entities": [(0,5, "FOOD")]}),
("Unagi is a famous seafood of Japan", {"entities": [(0,5, "FOOD")]}),
("Tempura , Soba are other famous dishes of Japan", {"entities": [(0,7, "FOOD")]}),
("Udon is a healthy type of noodles", {"entities": [(0,4, "ORG")]}),
("Chocolate soufflé is extremely famous french cuisine", {"entities": [(0,17, "FOOD")]}),
text = """Ted Kaczynski (better known as the Unabomber) received an invitation in 2012,
while incarcerated in the California, to his Harvard graduating class's 50th anniversary reunion.
He RSVPed, noting his occupation as 'prisoner' and his eight life sentences as 'awards in his college'
"""
"""From 8 am , Mr.X will be speaking on your favorite channel 191.1. Afterward there shall be an exclusive interview with actor Vijay on channel 194.1 . Hope you are having a great day. Call us on 666666"""
# Input text
engg_text = """If you study aeronautical engineering, you could specialize in aerodynamics, aeroelasticity,
composites analysis, avionics, propulsion and structures and materials. If you choose to study chemical engineering, you may like to specialize in chemical reaction engineering, plant design, process engineering, process design or transport phenomena. Civil engineering is the professional practice of designing and developing infrastructure projects. This can be on a huge scale, such as the development of nationwide transport systems or water supply networks, or on a smaller scale, such as the development of single roads or buildings.
specializations of civil engineering include structural engineering, architectural engineering, transportation engineering, geotechnical engineering, environmental engineering and hydraulic engineering. Computer engineering concerns the design and prototyping of computing hardware and software.
This subject merges electrical engineering with computer science,
"""The little prince, I know it’s a children’s book but it addresses themes of loneliness, human nature and love. I think it’s very profound in a simplistic way. A reminder to always stay curious, creative and open."""
# Creating a doc on news articles
confidential_text="""Indian man has allegedly duped nearly 50 businessmen in the UAE of USD 1.6 million and fled the country in the most unlikely way -- on a repatriation flight to Hyderabad, according to a media report on Saturday.Yogesh Ashok Yariava, the prime accused in the fraud, flew from Abu Dhabi to Hyderabad on a Vande Bharat repatriation flight on May 11 with around 170 evacuees, the Gulf News reported.Yariava, the 36-year-old owner of the fraudulent Royal Luck Foodstuff Trading, made bulk purchases worth 6 million dirhams (USD 1.6 million) against post-dated cheques from unsuspecting traders before fleeing to India, the daily said.
The bought goods included facemasks, hand sanitisers, medical gloves (worth nearly 5,00,000 dirhams), rice and nuts (3,93,000 dirhams), tuna, pistachios and saffron (3,00,725 dirhams), French fries and mozzarella cheese (2,29,000 dirhams), frozen Indian beef (2,07,000 dirhams) and halwa and tahina (52,812 dirhams).
The list of items and
# Which amongst the following models is better in terms of:
# R-Squared, Adj R-Squared, AIC and BIC
model1 <- lm(mpg ~ wt + hp, data=mtcars)
model2 <- lm(mpg ~ wt + cyl, data=mtcars)
model3 <- lm(mpg ~ qsec + hp, data=mtcars)
@selva86
selva86 / ks_plot.R
Last active July 7, 2020 13:46
Function to create KS Plot using InformationValue R package
require(ggplot2)
ks_table <- InformationValue:::ks_table
ks_plot <- function (actuals, predictedScores) {
rank <- 0:10
ks_table_out <- ks_table(actuals = actuals, predictedScores = predictedScores)
perc_events <- c(0, ks_table_out$cum_perc_responders) * 100
perc_nonevents <- c(0, ks_table_out$cum_perc_non_responders) * 100
random_prediction <- seq(0, 100, 10)
# Input
library(ggplot2)
data(mpg, package="ggplot2")
mpg <- read.csv("http://goo.gl/uEeRGu")
g <- ggplot(mpg, aes(x=displ, y=hwy)) +
geom_point() +
geom_smooth(method="lm") +
theme_bw()
plot(g)
# Modify the following code to remove the legend title. Then, place the legend in top left position
gg <- ggplot(midwest, aes(x=area, y=poptotal)) + # Define Data
geom_point(aes(col=state, size=popdensity)) + # Add scatterplot
geom_smooth(method="lm", col="firebrick", se=F) + # Add best fit line
coord_cartesian(xlim=c(0, 0.1), ylim=c(0, 250000)) + # Limit X and Y axis
labs(title="Area Vs Population", y="Population", x="Area") # Labels
plot(gg)