mood.learn_sentiments¶
Learning sentiments from data.
Functions
|
Fits a logistic regression model on embedding data for binary classification without feature scaling. |
|
Convert a multi-class target array to a binary array for a specific target class. |
|
Helper function to make predictions with a fitted model. |
Classes
|
Container for model performance statistics |
- class mood.learn_sentiments.ModelStatistics(accuracy=None, precision=None, recall=None, f1=None, roc_auc=None, confusion_matrix=None, classification_report=None, train_test_performed=False, training_time=None, test_size=None, random_state=None)[source]¶
Bases:
objectContainer for model performance statistics
- mood.learn_sentiments.fit_logistic_classifier(X, y, *, test_size=0.2, random_state=42, c_value=1.0, max_iter=1000, solver='lbfgs', penalty='l2', class_weight=None, fit_intercept=True, skip_validation=False, verbose=True)[source]¶
Fits a logistic regression model on embedding data for binary classification without feature scaling.
Parameters
- yarray-like, shape (n_samples,)
Binary target values (0/1 or True/False).
- test_sizefloat, default=0.2
Proportion of the dataset to include in the test split.
- random_stateint, default=42
Controls the shuffling applied to the data before applying the split.
- c_valuefloat, default=1.0
Inverse of regularization strength; smaller values specify stronger regularization.
- max_iterint, default=1000
Maximum number of iterations taken for the solvers to converge.
- solverstr, default=’lbfgs’
Algorithm to use in the optimization problem (‘newton-cg’, ‘lbfgs’, ‘liblinear’, ‘sag’, ‘saga’).
- penaltystr, default=’l2’
Specify the norm used in the penalization (‘l1’, ‘l2’, ‘elasticnet’, None).
- class_weightdict or ‘balanced’, default=None
Weights associated with classes. If ‘balanced’, uses class frequencies.
- fit_interceptbool, default=True
Whether to fit an intercept term in the model.
- skip_validationbool, default=False
If True, skips train/test validation and fits model on all data.
- verbosebool, default=True
If True, prints progress and results.
Returns
- statsModelStatistics
Object containing performance statistics.
- Return type:
tuple[LogisticRegression,ModelStatistics]