Giter VIP home page Giter VIP logo

islr-python's People

Contributors

jwarmenhoven avatar njannasch 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

islr-python's Issues

Have you tried rpy2?

I've also transcribed the Statistical Learning material into Python but only for my own reference. Yours is very elegant and I wish I'd discovered it at the beginning of the course rather than the end.

I noticed that you've gone to the extra step of dumping the R data to file and then loading into the Python environment in Jupyter. In my notes I wanted to have the R and Python code on top of each other for easy reference, so I installed an R virtualenv and built a "bilingual" Jupyter kernel that handles both languages. So far I've had good results using this version of rpy2 with Python 3.5 to invoke R magics in Jupyter and intersperse the two languages in the same notebook.

See my attached notebook, in case you find it useful.
StatLearning_Chapter4R_inPython.ipynb.zip
ch4_screen_shot

glmnet load error

Library not loaded: /usr/local/opt/gcc/lib/gcc/9/libgfortran.5.dylib
Reason: image not found

AttributeError: module 'glmnet' has no attribute 'ElasticNet'

Hi,
I am trying to run a code same as for chapter 6 provided here:

When I reach the point:
In[7]:

     grid = 10**np.linspace(10,-2,100)

     ridge3 = gln.ElasticNet(alpha=0, lambda_path=grid)
     ridge3.fit(X, y)

I get this error:

AttributeError Traceback (most recent call last)
in ()
1 grid = 10**np.linspace(10,-2,100)
2
----> 3 ridge3 = gln.ElasticNet(alpha=0, lambda_path=grid)
4 ridge3.fit(X, y)

AttributeError: module 'glmnet' has no attribute 'ElasticNet'

What can I do about it?

Chapter 8: Fix pydot and output from graphviz

I moved my local repository to another environment and need to fix the graphviz/pydot setup to be able to create the graphical representation of the decision trees. I accidently pushed an update to GitHub.

Chapter 3 - Figure 3.2 : RSS contour plot not symmetrical

What seems to be the problem with this plot? I think I created the meshgrid correctly, but it does not have the symmetrical shape as the one in the book.

Python
fig3_2_python

ISL
fig3_2

I contacted Trevor Hastie to ask him about the R code for plot on the left. He was so kind to send me the following code. You will need to load the advertising data first and skip the first two lines and the last line.

load("Chapter3.RData")
postscript(file="../Figs/leastsqexample1.ps",width=7,height=7,pointsize=14,horizontal=F)
set.seed(22)
par(mfrow=c(1,1),mar=c(5,5,2,2))
g=50
x=advertising$TV-mean(advertising$TV)
y=advertising$Sales
b=sum((x-mean(x))*(y-mean(y)))/sum((x-mean(x))^2)
a=mean(y)-b*mean(x)
RSS.min=sum((y-as.vector(cbind(1,x)%*%c(a,b)))^2)/100000
a.grid=seq(a-2,a+2,length=g)
b.grid=seq(b-.02,b+.02,length=g)
grid=as.matrix(expand.grid(a.grid,b.grid))

RSS=rep(0,g^2)
for (i in 1:(g^2)){
yhat=as.vector(cbind(1,x)%*%grid[i,])
RSS[i]=sum((y-yhat)^2)/1000
}
RSS=matrix(RSS,g,g)
m=which.min(RSS)

contour(a.grid-b*mean(advertising$TV),b.grid,RSS,xlab=expression(beta[0]),ylab=expression(beta[1]),levels=c(2.11,2.15,2.2,2.3,2.5,3),axes=T,frame.plot=T,col=4,drawlabels=T,cex.lab=1.5,labcex=1.3)

points(a-b*mean(advertising$TV),b,col=2,pch=19,cex=1.5)

dev.off()

Chapter 6: In[7] path

X_train = pd.read_csv('Data/Hitters_X_train.csv', index_col=0)
y_train = pd.read_csv('Data/Hitters_y_train.csv', index_col=0)
X_test = pd.read_csv('Data/Hitters_X_test.csv', index_col=0)
y_test = pd.read_csv('Data/Hitters_y_test.csv', index_col=0)

AttributeError in Chapter-8 notebook

Hi, when I exercuted the following snippet within chapter-8 Tree-based Methods.

graph2 = print_tree(clf, features=X2.columns, class_names=['No', 'Yes'])
Image(graph2.create_png())

Ipython gave me some error message

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-fc4f6f6b365b> in <module>()
      1 graph2 = print_tree(clf, features=X2.columns, class_names=['No', 'Yes'])
----> 2 Image(graph2.create_png())

AttributeError: 'list' object has no attribute 'create_png'

My python enviroment is anaconda python 3.5 + pydot 1.2.3. Any suggestion to fix this problem? Thanks

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.