GithubHelp home page GithubHelp logo

winvector / zmpdswr Goto Github PK

View Code? Open in Web Editor NEW
479.0 479.0 1.1K 173.34 MB

Example R scripts and data for "Practical Data Science with R" 1st edition by Nina Zumel and John Mount (Manning Publications)

Home Page: https://www.manning.com/books/practical-data-science-with-r

License: Other

R 11.08% Shell 0.28% HTML 88.63% Python 0.01%

zmpdswr's People

Contributors

johnmount avatar mariusbutuc avatar ninazumel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zmpdswr's Issues

Hello

Nice to meet you. Who are you

Possible function error ?

Hi, sorry for bothering you. I have a small question regarding to the function for calculating the squared distance between two vectors on Chapter 8.

In the book the function is :

sqr_edist <- function(x, y) {
sum((x-y)^2)
}

but don't you need to square root it after the calculation. so it'll be like :

sqr_edist <- function(x, y) {
sqrt( sum( (x-y)^2 ) )
}

Thanks for helping out.

Issue with example_5.14_of_section_5.2

Hi, I'm working through the book and I have an issue with the following example: 00070_example_5.14_of_section_5.2.5.R

When running outer(1:n,1:n,function(a,b) d[a,'cluster']) I get the following error Error in dim(robj) <- c(dX, dY) : dims [product 529] do not match the length of object [1].

I'm not using the original dataset but my data has the same format.

Re-writing the code this way fixes the issue

n <- dim(d)[[1]]
pairs <- merge(1:n,1:n,all=TRUE)
names(pairs) <- c("a", "b")
pairs$ca <- d[pairs$a,'cluster'][[1]]
pairs$cb <- d[pairs$b,'cluster'][[1]]
pairs$dist <- sqrt((d[pairs$a,'x']-d[pairs$b,'x'])^2 + (d[pairs$a,'y']-d[pairs$b,'y'])^2)[[1]]

dcast(pairs,ca~cb,value.var='dist',mean)

found issue in the function

Here,in chapter 6,there is a function I think something wrong.
while "pPosWna <- (naTab/sum(naTab))[pos] "can't get the stat that we want,
We really want the result is positive proportions,but the results are the negative ones.
have a try ,hope your answers,thanks.

mkPredC <- function(outCol,varCol,appCol) { # Note: 1
pPos <- sum(outCol==pos)/length(outCol) # Note: 2
naTab <- table(as.factor(outCol[is.na(varCol)]))
pPosWna <- (naTab/sum(naTab))[pos] # Note: 3
vTab <- table(as.factor(outCol),varCol)
pPosWv <- (vTab[pos,]+1.0e-3*pPos)/(colSums(vTab)+1.0e-3) # Note: 4
pred <- pPosWv[appCol] # Note: 5
pred[is.na(appCol)] <- pPosWna # Note: 6
pred[is.na(pred)] <- pPos # Note: 7
pred # Note: 8
}

F1 score in accuracyMeasures

Hi! Working my way through the book (love it so far!) and I had a question about how the F1 score is calculated in the accuracyMeasures function (

).

In Listing 9.1, it says that f1 is the product of precision and recall, which is how it's implemented in the code. Looking elsewhere, I see F1 defined as the harmonic mean or weighted average of precision and recall:
https://en.wikipedia.org/wiki/F1_score
http://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html

I didn't find anything in the errata, so I wanted to make sure that this was deliberate. Are there different definitions for the F1 score, or should I use a weighted average for F1 score in my code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.