How to clear tuples in a list (Python)

How to clear tuples in the list.

Code immediately

From the list called models I want to erase the tuple ('Perceptron', 0.52953807740324599).


models = [(name, score) for name, score in models if name != 'Perceptron']

#In models(name, score)The name of the part of
#'Perceptron'It means that only the one who is not will be left.

By the way, the contents of models look like this,

  KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
             metric_params=None, n_jobs=1, n_neighbors=5, p=2,
  DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
              max_features=None, max_leaf_nodes=None,
              min_impurity_split=1e-07, min_samples_leaf=1,
              min_samples_split=2, min_weight_fraction_leaf=0.0,
              presort=False, random_state=None, splitter='best')),
 ('SVM', SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
    decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
    max_iter=-1, probability=False, random_state=None, shrinking=True,
    tol=0.001, verbose=False)),
  LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
       intercept_scaling=1, loss='squared_hinge', max_iter=1000,
       multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,

Recommended Posts

How to clear tuples in a list (Python)
[Python] How to convert a 2D list to a 1D list
How to get a stacktrace in python
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
How to delete multiple specified positions (indexes) in a Python list
How to embed a variable in a python string
How to create a JSON file in Python
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to remove duplicate elements in Python3 list
[Python] How to use list 1
How to develop in Python
[Python] How to put any number of standard inputs in a list
How to format a list of dictionaries (or instances) well in Python
How to convert / restore a string with [] in python
[Python] How to expand variables in a character string
How to write a list / dictionary type of Python3
Things to note when initializing a list in Python
[Python] How to sort dict in list and instance in list
How to execute a command using subprocess in Python
[Python] How to output the list values in order
How to pass the execution result of a shell command in a list in Python
How to write a Python class
[Python] How to do PCA in Python
[python] Manage functions in a list
How to collect images in Python
How to use SQLite in Python
[Python] How to use list 3 Added
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to handle Japanese in Python
How to get a list of files in the same directory with python
[Python] How to make a list of character strings character by character
How to slice a block multiple array from a multiple array in Python
How to shuffle a part of a Python list (at random.shuffle)
A story about how to specify a relative path in python.
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
Developed a library to get Kindle collection list in Python
How to define multiple variables in a python for statement
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to identify the element with the smallest number of characters in a Python list?
How to check in Python if one of the elements of a list is in another list
How to find the first element that matches your criteria in a Python list
[Introduction to Python] How to use class in Python?
How to access environment variables in Python
How to dynamically define variables in Python
[Python] How to make a class iterable
How to do R chartr () in Python
Display a list of alphabets in Python 3
[Itertools.permutations] How to put permutations in Python
How to work with BigQuery in Python
[Python] How to invert a character string
How to display multiplication table in python
How to extract polygon area in Python
How to check opencv version in python
How to switch python versions in cloud9