{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"ds-1000","formal_name":"DS-1000","introduction":"DS-1000 builds 1,000 data-science problems from real StackOverflow questions across seven libraries including NumPy, Pandas and Matplotlib. The problems are perturbed so that recalling the original answer does not solve them.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://ds1000-code-gen.github.io/","indexing_mode":"index","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[],"history":"","construction":"","limitations":"","saturation":"","scores":[]}},"task_id":"e2e9e0f3-1b52-5d41-9e80-29fc89c49920","task_key":"default--test--900","task_revision_id":"1","upstream_id":"900","short_description":"When using SelectKBest or SelectPercentile in sklearn.feature_selection, it's…","config":"default","split":"test","body":"{\"library\":\"Sklearn\",\"prompt\":\"Problem:\\n\\nWhen using SelectKBest or SelectPercentile in sklearn.feature_selection, it's known that we can use following code to get selected features\\nnp.asarray(vectorizer.get_feature_names())[featureSelector.get_support()]\\nHowever, I'm not clear how to perform feature selection when using linear models like LinearSVC, since LinearSVC doesn't have a get_support method.\\nI can't find any other methods either. Am I missing something here? Thanks\\nNote use penalty='l1' and keep default arguments for others unless necessary\\n\\nA:\\n\\n<code>\\nimport numpy as np\\nimport pandas as pd\\nimport sklearn\\nfrom sklearn.feature_extraction.text import TfidfVectorizer\\nfrom sklearn.svm import LinearSVC\\ncorpus, y = load_data()\\nassert type(corpus) == list\\nassert type(y) == list\\nvectorizer = TfidfVectorizer()\\nX = vectorizer.fit_transform(corpus)\\n</code>\\nselected_feature_names = ... # put solution in this variable\\nBEGIN SOLUTION\\n<code>\\n\"}","display_format":"code","language":"","answer_status":"published","assets":[],"source_url":"https://ds1000-code-gen.github.io/","history":"initial import","indexing_mode":"index","subproblems":[],"grids":[]}