Add Features to An Sklearn Classifier

I'm building a SGDClassifier, and using a tfidf transformer. Aside from the features created from tfidf, I'd also like to add additional features like document length or other ratings. How can I add these features to the feature-set? Here is how the classifier is constructed in a pipeline:

data = fetch_20newsgroups(subset='train', categories=None) pipeline = Pipeline([ ('vect', CountVectorizer()), ('tfidf', TfidfTransformer()), ('clf', SGDClassifier()), ]) parameters = { 'vect__max_df': (0.5, 0.75, 1.0), 'vect__max_features': (None, 5000, 10000, 50000), 'vect__ngram_range': ((1, 1), (1, 2)), # unigrams or bigrams 'tfidf__use_idf': (True, False), } grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1, verbose=1) grid_search.fit(data.data, data.target) print(grid_search.best_score_)

-------------Problems Reply------------

You can use feature union http://scikit-learn.org/stable/modules/pipeline.html#featureunion-composite-feature-spaces

There is a nice example in the documentation http://scikit-learn.org/stable/auto_examples/hetero_feature_union.html#example-hetero-feature-union-py which I think exactly fits your requirements. See TextStats transformer.

Regards,

Category:python Views:4 Time:2016-06-16

Related post

  • How to create Google Calendar Quick Add feature in Java? 2011-09-29

    I am working on a school project that requires a little bit of Natural Language Processing. We have to implement a feature that is similar to Google Calendar Quick Add feature in Java. http://www.google.com/support/calendar/bin/answer.py?answer=36604

  • Add features to Windows 8.1 - is this product worth it? 2012-02-28

    Add features to Windows 8.1 - and you have the option to buy a product key online? Has anyone got the product key or bought the product key online and found that it was worth it please? --------------Solutions------------- Hello Nougart, It all reall

  • Error when trying to Add Features to Windows 8.1 2012-03-03

    Hello, Some weird problem has ocurred lately. When I search in the Charms bar for "Add Features" and then click on the concerning option that comes up (Add features to Windows 8.1), an "unspecified error" comes up showing a path to the Appdata direct

  • You can't add features to this edition of Windows 2012-06-06

    I have Windows 8.1 Pro Retail which i downloaded from here Download Windows 8 Pro ISO 32 Bit / 64 Bit Free Then i upgraded my Windows 8 Pro to Windows 8.1 Pro.I activated my Windows 8.1 and I want to add media center when i type add features to windo

  • Add Features to Windows 8 - replaced Anytime Upgrade 2012-10-08

    Windows 7 has an Anytime Upgrade option to upgrade to a higher version of Windows. In Windows 8 it has been replaced by Add Features to Windows 8 in Control Panel. There are three versions of Desktop Windows 8 - Core, Pro and Pro with WMC. When RP wa

  • Windows 8 Add Features will not accept Windows 8 Pro key 2012-11-08

    Hello all, I figured this was a good place to put this as I suspect it has to do with activation. I'm currently upgrading my friends windows 7 home machine to windows 8 pro.. I have already upgraded him to windows 8 using an already activated key (Th

  • Setting: Add features to Windows 8? 2013-01-03

    In the control panel, under System and Security, there is a section called "Add features to Windows 8". It then asks if I want to let W8 take over my computer. I didn't go any further. Anyone know what this does? If anything? --------------Solutions-

  • You Can't Add Features to this Version of Win 8.1 ANYMORE 2013-04-22

    Please help! I tried to use my license key to Add Features to Windows 8.1 but then I got that message. It didn't say that when I first did it! Confused, Bashan --------------Solutions------------- What version is installed? Core or Pro. What Features

  • How do I correct the Media Center add feature install problem that says "something went wrong" "close this wizard and try again" 2012-01-05

    When I first installed Windows 8 Pro it was on a clean drive but I forgot to turn on in my BIOS AHCI for my disks. With that set up I was successful in installing the media upgrade. Since I had not turned on AHCI I re-installed Win 8 on a reformatted

  • Unalbe to find 'Add Features' to activate Windows Media Center'. 2012-01-07

    Original title: add features. I request the key for Windows Media Player centre and cannot find the "add features" in the search --------------Solutions------------- See the following: http://techingiteasy.wordpress.com/2012/11/29/how-to-get-your-fre

  • ADD FEATURES 2012-01-08

    http://windows.microsoft.com/en-US/windows-8/feature-packs i have attempted to register for a Free Key but the site doesnt work i have been directed to this site by microsoft live chat with still no response if microsoft cannot even get the websites

  • Unable to add features to single language windows 8 pro. 2012-01-08

    SIR , I added features to single language, to windows 8 pro. when I entered key to activate it there is error that it could not be activated. and KMS could not be contacted. send messages to *** Email address is removed for privacy *** THANKS FOR HEL

  • can microsoft add feature to office 2012-01-25

    i have a suggestion. it might sound pretty stupid and lame. but i think it will benefit a lot of people if microsoft office had a feature where it can attach a youtube video link in word or powerpoint or anywhere else needed and a video window will a

  • Add features to Windows 8 missing / Trying to activate Windows Media Center 2012-02-04

    I have bought Microsoft Windows 8 Pro from the website, downloaded the .iso file and did a clean install. Once setup was done I typed in the activation key, activation successful. Now, I have received a free key for media center. However, the add fea

  • I have the PIN for windows 8 but when it says to click on settings and type in Add features to Windows 8, the search comes up blalnk, what can I do? 2012-02-12

    I bought a new computer yesterday and want to upgrade to Windows 8. I have 7 on my new laptop. I got the pin and put it in on the website I was sent to. However, it tells me to " On the Start screen, type Add features to Windows 8, and then click Set

  • windows 8 add features not working 2012-02-21

    I have Windows 8 pro x64 in my PC. When I try to add features after giving the key, it tells to activate windows first. But Windows is already activated on my PC. How to solve this problem? --------------Solutions------------- Hi Anirban Nath, If you

  • Windows Media Center via Add Features does not complete. 2012-02-23

    I just purchased a key for installing Media Center via Add Features for a recent Sony Vaio Duo with Windows 8 pre-installed (and upgraded to 8.1 since then). The installation completes with a very explicite message "Something went wrong". Start the W

  • Windows Media Center upgrade with Win 8 Pro offering .... where to find the "add features" page? 2012-03-04

    I recently bought and installed Windows 8 Pro on a new HP laptop and received the key, by email, to install "free" the Windows Media Center program before end of January. I am not getting the process they are asking me to follow in setting/installing

  • Why does my Windows 8.1 Pro have the option "Add features to Windows 8.1"? 2012-03-28

    Hi, Today I installed a full retail version of Windows 8.1 Pro on my Lenovo H520g desktop. I have legally purchased the Windows 8.1 Pro DVD on a local Microsoft reseller. My Lenovo H520 desktop came with Windows 8 Sl pre-installed and as November 201

  • Windows 8.1 - add features 2012-04-12

    Original Title : *** Email address is removed for privacy *** I had Windows 8 PRO installed and added Hyper-V. Created virtual machines to do some tests. Later I upgraded, online, to Windows 8.1, no problem, Hyper-V was there. Then my computer crashe

  • Add features asks for a key but my key is embedded, activated and windows does not show it. How can I get the key to insert when it is asked? 2012-04-20

    I have a preinstalled win8 Pro with Asus notebook. I would like to install Itunes but installer does not work. I found that I need media center to make it install. To install media center i have to rund "add features" from setting. WHen I run it it a

  • Add features to windows 8 wont open. I want to get my free version of Windows Media Center. 2012-04-23

    I recently bought Windows 8 (x64) for my pc. I noticed that you can get Windows Media Center for free for a limited time. I have received my activation code in my e mail, but when I go to add features, nothing happens. Can somebody tell me what is go

  • Add Features is not working? 2012-05-05

    Ok, I purchased online from MS an upgrade for existing pc Windows 8 Pro. I was offered for a limited time to get Windows Media Pack for free. I took that offer and received a key for it along with a key obviously for the Windows 8 Pro. I've got W8 Pr

  • Windows 8 Pro & "Add features to Windows 8" Missing 2012-05-12

    I'm running Windows 8 Pro from MSDN. It's activated, updated, yet I don't have the option to "Add features to Windows 8." No dice executing it from command line either as admin control /name Microsoft.WindowsAnytimeUpgrade Thanks for your help! -----

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.083 (s). 11 q(s)