# 菜鸟 机 学 的 逆袭 之 路 # day11

// mean () function: find the mean

The frequently operated parameter is axis, taking m * n matrix as an example:

axis does not set a value, average the m * n numbers, and returns a real number

axis = 0: average the columns and return a 1 * n matrix

axis = 1: average the rows and return the m * 1 matrix

//Sklearn.svm.LinearSVC(penalty=’l2’, loss=’squared_hinge’, dual=True, tol=0.0001, C=1.0, multi_class=’ovr’,fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000)

penalty: string, 'l1' or 'l2' (default = 'l2')
specifies the specification used in the penalty. The 'l2' penalty is the standard used in SVC. 'l1' results in a sparse coef_vector.

loss: string, 'hinge' or 'squared_hinge' (default = 'squared_hinge')
specifies the loss function. "Hinge" is the standard SVM loss (for example used by the SVC class), and "squared_hinge" is the square of the hinge loss.

dual: bool, (default = True)
Select the algorithm to solve the double optimization or original optimization problem. When n_samples> n_features, dual = False is preferred.

tol: float, optional (default = 1e-4)
Tolerance stop standard

C: float, optional (default = 1.0)
error parameter

multi_class: string, 'ovr' or 'crammer_singer' (default = 'ovr')
If y contains more than two classes, then determine the multi-class strategy. "Ovr" trains the n_classes one-vs-rest classifier, while "crammer_singer" optimizes the joint goal of all classes. Although crammer_singer is interesting in theory because it is consistent, it is rarely used in practice because it rarely improves accuracy and is more computationally expensive. If "crammer_singer" is selected, the options loss, penalty and dual will be ignored.

fit_intercept: boolean, optional (default = True)
Whether to calculate the intercept of this model. If set to false, the intercept will not be used in the calculation (ie, the data is expected to be centered).

intercept_scaling: float, optional (default = 1)
When self.fit_intercept is True, the instance vector x becomes [x, self.intercept_scaling], that is, a “composite” feature with a constant value equal to intercept_scaling is added to the instance vector. The intercept becomes intercept_scaling * Composite feature weight attention! The synthetic feature weights undergo l1 / l2 regularization like all other features. In order to reduce the effect of regularization on the weight of the synthesized features (and therefore the intercept), intercept_scaling must be increased.

class_weight: {dict, 'balanced'}, optional
Set the parameter C of class i to SVC's class_weight [i] * C. If not given, all courses should have a weight. "Balance" mode uses the value of y to automatically adjust the weight that is inversely proportional to the class frequency in the input data, such as n_samples / (n_classes * np.bincount (y))

verbose: int, (default = 0)
enable verbose output. Please note that this setting takes advantage of the per-process runtime settings in liblinear. If enabled, it may not work properly in a multi-threaded context.

random_state: int, RandomState instance or None, optional (default = None)
Seed of the pseudo-random number generator used when random data is shuffled. If it is int, random_state is the seed used by the random number generator; if it is a RandomState instance, then random_state is the random number generator; if it is None, then the random number generator is the RandomState instance used by np.random.

max_iter: int, (default = 1000)
The maximum number of iterations to run.

Reprinted from https://blog.csdn.net/weixin_41990278/article/details/93165330

The zip () function takes an iterable object as a parameter, packs the corresponding elements in the object into tuples, and then returns a list of these tuples.

If the number of elements in each iterator is inconsistent, the length of the returned list is the same as the shortest object. Using the * operator, you can decompress the tuple into a list.
usage:

a = [1,2,3]
b = [4,5,6]
c = [4,5,6,7,8]
zipped = zip (a, b) # packed as a list of tuples
[(1, 4), (2, 5), (3, 6))

zip (a, c) # The number of elements is consistent with the shortest list
[(1, 4), (2, 5), (3, 6)]

zip (* zipped) # Contrary to zip, * zipped can be understood as decompression, returning a two-dimensional matrix
[(1, 2, 3), (4, 5, 6)]

Published 31 original articles · praised 0 · visits 693

Guess you like

Origin blog.csdn.net/ballzy/article/details/104815354