from tqdm import tqdm
import pycrfsuite
from crf_tagger._fileresource import FileResource
from crf_tagger.trainer import LinePerIterationTrainer
from crf_tagger.compat import BaseEstimator
class CRF(BaseEstimator):
"""
python-crfsuite wrapper with interface siimlar to scikit-learn.
It allows to use a familiar fit/predict interface and scikit-learn
model selection utilities (cross-validation, hyperparameter optimization).
Unlike pycrfsuite.Trainer / pycrfsuite.Tagger this object is picklable;
on-disk files are managed automatically.
Parameters
----------
algorithm : str, optional (default='lbfgs')
Training algorithm. Allowed values:
* ``'lbfgs'`` - Gradient descent using the L-BFGS method
* ``'l2sgd'`` - Stochastic Gradient Descent with L2 regularization term
* ``'ap'`` - Averaged Perceptron
* ``'pa'`` - Passive Aggressive (PA)
* ``'arow'`` - Adaptive Regularization Of Weight Vector (AROW)
min_freq : float, optional (default=0)
Cut-off threshold for occurrence
frequency of a feature. CRFsuite will ignore features whose
frequencies of occurrences in the training data are no greater
than `min_freq`. The default is no cut-off.
all_possible_states : bool, optional (default=False)
Specify whether CRFsuite generates state features that do not even
occur in the training data (i.e., negative state features).
When True, CRFsuite generates state features that associate all of
possible combinations between attributes and labels.
Suppose that the numbers of attributes and labels are A and L
respectively, this function will generate (A * L) features.
Enabling this function may improve the labeling accuracy because
the CRF model can learn the condition where an item is not predicted
to its reference label. However, this function may also increase
the number of features and slow down the training process
drastically. This function is disabled by default.
all_possible_transitions : bool, optional (default=False)
Specify whether CRFsuite generates transition features that
do not even occur in the training data (i.e., negative transition
features). When True, CRFsuite generates transition features that
associate all of possible label pairs. Suppose that the number
of labels in the training data is L, this function will
generate (L * L) transition features.
This function is disabled by default.
c1 : float, optional (default=0)
The coefficient for L1 regularization.
If a non-zero value is specified, CRFsuite switches to the
Orthant-Wise Limited-memory Quasi-Newton (OWL-QN) method.
The default value is zero (no L1 regularization).
Supported training algorithms: lbfgs
c2 : float, optional (default=1.0)
The coefficient for L2 regularization.
Supported training algorithms: l2sgd, lbfgs
max_iterations : int, optional (default=None)
The maximum number of iterations for optimization algorithms.
Default value depends on training algorithm:
* lbfgs - unlimited;
* l2sgd - 1000;
* ap - 100;
* pa - 100;
* arow - 100.
num_memories : int, optional (default=6)
The number of limited memories for approximating the inverse hessian
matrix.
Supported training algorithms: lbfgs
epsilon : float, optional (default=1e-5)
The epsilon parameter that determines the condition of convergence.
Supported training algorithms: ap, arow, lbfgs, pa
period : int, optional (default=10)
The duration of iterations to test the stopping criterion.
Supported training algorithms: l2sgd, lbfgs
delta : float, optional (default=1e-5)
The threshold for the stopping criterion; an iteration stops
when the improvement of the log likelihood over the last
`period` iterations is no greater than this threshold.
Supported training algorithms: l2sgd, lbfgs
linesearch : str, optional (default='MoreThuente')
The line search algorithm used in L-BFGS updates. Allowed values:
* ``'MoreThuente'`` - More and Thuente's method;
* ``'Backtracking'`` - backtracking method with regular Wolfe condition;
* ``'StrongBacktracking'`` - backtracking method with strong Wolfe
condition.
Supported training algorithms: lbfgs
max_linesearch : int, optional (default=20)
The maximum number of trials for the line search algorithm.
Supported training algorithms: lbfgs
calibration_eta : float, optional (default=0.1)
The initial value of learning rate (eta) used for calibration.
Supported training algorithms: l2sgd
calibration_rate : float, optional (default=2.0)
The rate of increase/decrease of learning rate for calibration.
Supported training algorithms: l2sgd
calibration_samples : int, optional (default=1000)
The number of instances used for calibration.
The calibration routine randomly chooses instances no larger
than `calibration_samples`.
Supported training algorithms: l2sgd
calibration_candidates : int, optional (default=10)
The number of candidates of learning rate.
The calibration routine terminates after finding
`calibration_samples` candidates of learning rates
that can increase log-likelihood.
Supported training algorithms: l2sgd
calibration_max_trials : int, optional (default=20)
The maximum number of trials of learning rates for calibration.
The calibration routine terminates after trying
`calibration_max_trials` candidate values of learning rates.
Supported training algorithms: l2sgd
pa_type : int, optional (default=1)
The strategy for updating feature weights. Allowed values:
* 0 - PA without slack variables;
* 1 - PA type I;
* 2 - PA type II.
Supported training algorithms: pa
c : float, optional (default=1)
Aggressiveness parameter (used only for PA-I and PA-II).
This parameter controls the influence of the slack term on the
objective function.
Supported training algorithms: pa
error_sensitive : bool, optional (default=True)
If this parameter is True, the optimization routine includes
into the objective function the square root of the number of
incorrect labels predicted by the model.
Supported training algorithms: pa
averaging : bool, optional (default=True)
If this parameter is True, the optimization routine computes
the average of feature weights at all updates in the training
process (similarly to Averaged Perceptron).
Supported training algorithms: pa
variance : float, optional (default=1)
The initial variance of every feature weight.
The algorithm initialize a vector of feature weights as
a multivariate Gaussian distribution with mean 0
and variance `variance`.
Supported training algorithms: arow
gamma : float, optional (default=1)
The tradeoff between loss function and changes of feature weights.
Supported training algorithms: arow
verbose : bool, optional (default=False)
Enable trainer verbose mode.
model_filename : str, optional (default=None)
A path to an existing CRFSuite model.
This parameter allows to load and use existing crfsuite models.
By default, model files are created automatically and saved
in temporary locations; the preferred way to save/load CRF models
is to use pickle (or its alternatives like joblib).
"""
def __init__(
self,
algorithm=None,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:crf_tagger-0.3.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
crf_tagger-0.3.1.tar.gz (11个子文件)
crf_tagger-0.3.1
PKG-INFO 523B
pyproject.toml 398B
setup.py 642B
crf_tagger
estimator.py 16KB
utils.py 181B
metrics.py 2KB
_fileresource.py 2KB
compat.py 39B
__init__.py 37B
trainer.py 2KB
scorers.py 335B
共 11 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JAVA基于SSM的java智能制造系统源码数据库 MySQL源码类型 WebForm
- matlab求解热传导实例 matlab求解热传导问题的几个例子.pdf
- 数字人软件安装包.apk
- 偏微分方程数值解法的MATLAB源码 一阶双曲型方程数值解法及其MATLAB实现.docx
- 基于MATLAB一维热传导方程的模拟程序.docx
- 基于matlab的一维偏微分方程的pdepe函数解法 MATLAB环境中利用pdepe函数求解一维偏微分方程的技术.docx
- JAVA的Springboot+vue在线考试系统源码数据库 MySQL源码类型 WebForm
- 机器学习2.ipynb
- 传热学大作业-利用matlab程序解决热传导问题 传热学MATLAB数值模拟-热传导问题与高斯-赛德尔迭代法.docx
- PDE求三维的数值 热传导方程.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功