Warning Messages in Jupyter Notebook Example Code

You’re working with the downloadable source code from a book like  Algorithms for Dummies, 2nd EditionBeginning Programming with Python For Dummies, 3rd EditionMachine Learning for Dummies, 2nd EditionPython for Data Science for Dummies, or Machine Learning Security Principles and see a warning message like this:

C:\Users\John\anaconda3\lib\site-packages\sklearn\feature_selection\_sequential.py:206: FutureWarning: Leaving `n_features_to_select` to None is deprecated in 1.0 and will become 'auto' in 1.3. To keep the same behaviour as with None (i.e. select half of the features) and avoid this warning, you should manually set `n_features_to_select='auto'` and set tol=None when creating an instance.
  warnings.warn(

Well, that’s pretty confusing looking and if you’re just learning to work with Python may give you the idea that you’ve done something seriously wrong. There are a couple things to note here. First, this is a warning message. In fact, it’s a FutureWarning message, which means the change mentioned in the warning hasn’t actually taken effect yet.

Second, if you’re using the version of Jupyter Notebook and Python mentioned in the book, it’s unlikely that the effects described in the message will become a problem anytime soon, so you can usually ignore them. (This is one reason that I always ask which version of Jupyter Notebook and Python you’re using because a newer version can definitely cause error messages to appear.) Of course, if this warning ever does turn into an error, Luca and I definitely want to hear about it at [email protected].

Third, the message does state a potential fix for the problem. If the fix is simple enough, you can always try to make the required change to see if it works. However, this is a do it at your own risk sort of modification. The point is that the warning isn’t keeping you from using the downloadable source today, so ignoring it is probably the best action to take.

If you really don’t want to see these warnings, you can always add two lines of code the to first cell of the downloadable source. The warning isn’t actually going away, you just won’t see it:

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

So, what causes these warning messages in the first place? Is the book’s source code faulty? There is nothing wrong with the book’s source code. What you’re seeing is the result of a library upgrade. Python uses a huge number of libraries and a change in any one of them can create a warning message of the sort you’ve seen. Luca and I work hard to ensure that the source code you get with the book is functional (and warning free) on all of the supported platforms at the time of writing, but it would be impossible for us to constantly update the book’s code to keep up with these library changes.

Future of Libraries?

This is an update of a post that originally appeared on June 9, 2011.

Despite my leanings toward an entirely new kind of library when I wrote this post nearly twelve years ago, the library today seems much like the library back then, with a few changes. I still don’t actually visit my library to view the stock of books anymore. All I need to do is go to the library’s site online, look for the book I want by anything that comes to mind, and then order the book. I physically go to the library to pick the physical book up later. However, I still see the future, as described by devices such as the Kindle and the serious increase in audiobook usage, as electronic. In fact, I just recently had my first audiobook published, something I thought might never happen. The one thing that has taken me by surprise is the self-checkout library. I imagine that self-checkout has made the librarian’s life a lot easier, but I wonder about the cost of personal contact with patrons. Will we eventually stop talking to each other completely?

I had touched on the topic ebook usage a little in my “Paper or eBook?” post, but didn’t take the discussion to a logical conclusion at that point. What will happen when the library becomes completely electronic? It could happen—probably not within my lifetime, but definitely within the lifetime of the next generation. It could eventually happen that you’ll receive a device that connects to a worldwide library and delivers only electronic media. There are a number of advantages to this arrangement:

  • A book would be at your disposal 24/7 without much effort on your part at all.
  • There is no limit to the number of people who could view a book.
  • Rare or exotic books could be scanned and made available electronically.
  • Reading would become a do anywhere sort of activity that might actually benefit children who don’t currently read nearly enough.
  • Money would no longer define access to knowledge.

This future world has a few problems, of course. The people who put creative talent into materials of all sorts are already under attack today. Many people feel no need to pay for the materials they use—the information should be free in their minds. Barriers still exist to some degree and most people realize that people with creative talent require compensation in order to live, but the library of the future will make such barriers non-existent. How will someone who writes, draws, sings, or does anything else creative survive in a world where free electronic forms of everything exist? (Libraries are allowed to bypass copyright under certain conditions and I don’t see a problem with these exemptions, but there is a balance to maintain.)

I imagine that artists of all sorts will need to find some other means of support in the future. (In fact, my business has changed considerably over the past twelve years for this very reason.) Perhaps the government will step in and provide compensation to artists from library fees or taxes (it seems doubtful here in the US). Certainly, the current system of copyright is breaking down already. I read about copyright issues almost daily online in articles such as this one on ComputerWorld. The problem is that a lot of people talk about copyright, but few do anything about it. However, legislating morality has never worked in the history of the world and I doubt very much it will work now, especially considering what I see happening in government funded agencies such as libraries. Change is inevitable, if not always good. Then again, I can’t see this particular change as necessarily bad (despite not necessarily wanting to live it myself—call me attached to the physical book or simply outdated).

What sorts of changes are you seeing in your local library? Where do you feel these changes will end? How will people of a creative bent be compensated in the future? I’d love to hear your views on any or all of these questions at [email protected].

Python Community Support

This is an update of a post that originally appeared on October 13, 2014.

There are many issues to consider when choosing a programming language. Python is no exception. Just because I feel it’s the right tool to meet some of my needs doesn’t mean it will work well for you. That’s why the Understanding Why Python is So Cool section of Chapter 1 in Beginning Programming with Python For Dummies, 3rd Edition is so important. This section tells you why I see Python as an important programming language and why you might want to use it too. I break the problem into three parts: what Python can do for your application needs, how Python can benefit you personally, and which organizations are using Python for specific tasks. Between the three sections, you can make an intelligent decision as to whether Python will actually serve your particular needs. I really don’t want you to take my word for it—I would rather know that you selected Python based on your own research.

No matter how interesting a language is, no matter how many features it provides, and no matter how much you personally like it—you can’t typically learn a language that lacks broad community support with any ease. If no one else is using the language and contributing to it in some major way, the language will eventually die. Fortunately, Python doesn’t have this problem. Chapter 21 of my book discusses ten essential libraries for Python, none of which come with the language when you download it. In fact, the introduction to this chapter lists a number of places where you can find even more libraries to use.

The thing is that Python keeps attracting ever more attention. A recent Dev article, 10 Best Tools Python Programmers Can Learn in 2023, provides you with access to tools you really need to know about. The point about tools is that they represent an essential form of community support. As people use a language, they start to build places where others can discuss it with them. However, that’s only one form of community support. Tools represent a significant increase in support because creating, debugging, and supporting a tool requires time and effort that most developers don’t have in abundance. Someone really has to believe in a language to provide this sort of language support.

The fact is that Python has become a “must learn” language. It has great community support, provides a broad range of functionality through libraries and tools, and is fully supported by the academic community. Even though other languages have had these advantages and eventually failed, the chances are far less likely that Python will experience problems. In fact, many rankings sites show Python as being the most popular language out there right now.

Community support is an essential determinant of programming language popularity. How do you rank Python in your toolbox and why? Let me know at [email protected]. Tell me about your favorite Python library or tool and how you use it as well. (No vendor emails please, I want to hear from developers who are actually using products.) I’m interested in discovering just what makes some languages so incredibly popular (Python being one of the most popular).

The Ongoing Evolution of Libraries

I read a news story this weekend that confirms some of the things I’ve been saying about the future of libraries. The story, Texas library offers glimpse of bookless future, describes a new library in Texas, Bexar County’s BiblioTech, that doesn’t actually contain any books. This library contains computers and e-book readers that people use to work with content electronically. The article states that a lot of people are looking at this library to see how successful it becomes because the cost of maintaining such a library is significantly less than a traditional library. In fact, advances in technology will continue to make it possible to further reduce the cost of maintaining this particular kind of library.

However, I’ve been exploring a question for a while now about the future viability of libraries as physical entities. I first described this particular issue in my A New Emphasis On Libraries post. For 3 ½ years now I’ve tried to expand on the theme discussed in the Future of Libraries? post. The problem with a library that serves up only electronic media is that it’s overkill. Eventually, such libraries will disappear because people will be able to find the content online. A national library that’s based on the Internet will eventually take hold and that will be the death knell for the local library.

Something that the article brings up is that this library serves a neighborhood where few people have the hardware required to read electronic books and there is no Wireless Fidelity (WiFi) connection in the area for them to use. At one time rural areas didn’t have telephones because it was too expensive to service them. Now rural areas have good satellite or Digital Subscriber Line (DSL) connections. It won’t be long before rural and less serviced areas in cities have WiFi connectivity. So, the first problem this library solves won’t be a long term condition. We’re in a transitional phase.

The devices used to read books electronically will continue to evolve and become less expensive. At some point, the government will figure out that it’s less expensive to simply issue a device to those in need, rather than build physical libraries. At that point, a virtual national library will become feasible and probably appear on the scene. Paper books will eventually be relegated to the niche market—sold to those who have the money required to buy such products.

I’m one of the few, I’m sure, who will miss the paper book when this change happens. Using e-books for technical reading really is quite nice, but the feel of paper when I read fiction just can’t be overcome by the convenience of using an e-book reader. At one time I predicted that paper would continue to be available and preferred to meet my fiction needs, but things have changed faster than I could have ever predicted. It may very well be that the transition to e-book as the only viable media will happen within the next few years—only time will tell.

What do you feel about the transition to e-books and virtual libraries? If you like the idea of being able to find any book and check it out using a virtual library, let me know how you envision this system working. More importantly, how will such a system compensate authors for the time and effort spent putting the books together? Send me your ideas to [email protected].

 

A New Emphasis On Libraries

I’ve been talking with a friend about libraries recently. He had noted that the only people he had seen using libraries lately were older; that children had no desire whatsoever to even enter a library. Of course, this bodes ill for the institution because the youth of today will be the supporters of libraries tomorrow. However, his observations don’t match my own. Our local libraries seem to be packed with children. In fact, I saw three children standing outside our local library the other day while waiting for the doors to open. The difference in these two observations has me quite curious.

The way in which people use libraries has always interested me because these public warehouses of knowledge are essential to a functioning society. People require some method of accessing exotic or expensive texts—especially people who have limited means. The way in which libraries present information to the public will change in the future, but I have no doubt they will remain. In fact, I’ve touched on this topic before in my “Future of Libraries?” post. Before a future kind of library can take shape, however, the children of today must be engaged in the materials that a library can provide and see these materials as useful.

The two of us are still discussing the topic of libraries because the differences in our observations provide good fodder for discourse on the topic. My thought is that the differences in our observations could come from a number of sources:

 

  • A difference in the community (small town versus large city)
  • Differences in the society (such as, beach community versus Midwest farming community)
  • Times of observation
  • Motivation level of the librarians manning the library
  • Perceived value of the library’s content


Our local library is blessed with a great librarian and strong support from volunteers who truly care that we have a library. For example, we actually host events at our library to get people engaged and to enter the building so they can see what the library has to offer. The state has also been running ads to help support the local libraries and those ads may be boosting the number of people the library sees. Whatever the difference, I’m truly happy to see children waiting for the doors to open at our community library.

Of course, I always want to hear your opinion. What level of participation do you see at your local library? Who goes there and what seems to interest them most? What do you see as factors that affect participation in your local library? Let me know your thoughts at [email protected]