标签: scikits

Scikits Learn:线性内核SVM中的特征权重

我正在处理文本分类问题(情绪分析).我想知道scikit中是否有任何选项 - 学习为特征添加"权重"(作为重要性的度量).我检查了文档并找到了SVC的属性"coefs",定义如下:

    coef_   array, shape = [n_class-1, n_features]  
    Weights asigned to the features (coefficients in the primal problem). 
   This is only available in the case of linear kernel.coef_ is readonly property derived from dual_coef_ and support_vectors_ 
Run Code Online (Sandbox Code Playgroud)

但是,此属性似乎是只读的.

machine-learning svm feature-selection scikits scikit-learn

2
推荐指数
1
解决办法
2121
查看次数

使用SciKit-learn和大型数据集进行文本分类

首先,我昨天开始使用python.我正在尝试使用SciKit和大型数据集(250.000条推文)进行文本分类.对于算法,每个推文将表示为4000 x 1向量,因此这意味着输入为250.000行和4000列.当我尝试在python中构造它时,我在8500条推文之后耗尽内存(当使用列表并附加它时)并且当我预先分配内存时我只得到错误:MemoryError(np.zeros(4000,2500000)).SciKit无法使用这些大型数据集吗?我做错了什么(因为这是我第二天用python)?是否有另一种表示功能的方式,以便它可以适合我的记忆?

编辑:我想要伯努利NB

edit2:也许有可能通过在线学习?阅读推文,让模特使用推文,将其从内存中删除,阅读另一个,让模型学习......但我不认为伯努利NB允许在scikit-learn中进行在线学习

python nlp scikits scikit-learn

2
推荐指数
1
解决办法
2551
查看次数

使用新数据更新SVM分类器

我用Python训练了一个SVM分类器

clf = sklearn.svm.NuSVC(nu=0.05, probability=True, kernel='rbf')
clf.fit(points, classes)
Run Code Online (Sandbox Code Playgroud)

这对预测很有用.现在我想更新分类器参数.几点不会改变分类(从正数到零),还会添加一些分数.少数意味着10000或更多的50.

我认为提示SVM分类器从先前的参数开始是明智的,这应该非常接近最佳解决方案.我有一个问题,有时,分类器随机非常差(我认为拟合失败).有没有办法在scikit-learn或libsvm中这样做?

python svm libsvm scikits scikit-learn

2
推荐指数
1
解决办法
1346
查看次数

安装scikits.samplerate失败

我想使用"scikits.samplerate",但安装失败.我正在使用Windows10(64位)与Anaconda的Python 3.51.

首先,我遵循了这条指令:https: //scikits.appspot.com/samplerate

>pip install scikits.samplerate Collecting scikits.samplerate   Using cached scikits.samplerate-0.3.3.tar.gz
    Complete output from command python setup.py egg_info:
    SamplerateInfo:
      libraries samplerate not found in c:\users\username\anaconda3\lib
      libraries samplerate not found in C:\
      libraries samplerate not found in c:\users\username\anaconda3\libs
    Traceback (most recent call last):
      File "scikits\samplerate\setup.py", line 15, in configuration
        sf_config = sf_info.get_info(2)
      File "c:\users\username\anaconda3\lib\site-packages\numpy\distutils\system_info.py", line 568, in get_info
        raise self.notfounderror(self.notfounderror.__doc__)
    numpy.distutils.system_info.NotFoundError: Some third-party program or library is not found.

    During handling of the above exception, another exception occurred: …
Run Code Online (Sandbox Code Playgroud)

python install scikits anaconda

2
推荐指数
1
解决办法
2617
查看次数

安装Scikits.audiolab时出错

我正在尝试用pip安装scikits.audiolab.我读过这篇文章,然而,看起来用户的问题是他们没有安装numpy.我可以通过卸载numpy并运行来复制它们的跟踪pip install scikits.audiolab.我有numpy时得到的痕迹是:

numpy.distutils.system_info.NotFoundError: sndfile (http://www.mega-nerd.com/libsndfile/) library not found.
Directories to search for the libraries can be specified in the
site.cfg file, in section [sndfile].

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/p8/tbdq1bmx54d68dftpx9_p6qr0000gn/T/pip-build-vuIg71/scikits.audiolab/
Run Code Online (Sandbox Code Playgroud)

我发现有关此错误的所有内容都指向我从pypi下载scikits.audiolab并运行python setup.py install,这显然是"静态链接到libsndfile".但是当我按照这些说明操作时,我得到了几乎相同的错误:

numpy.distutils.system_info.NotFoundError: sndfile (http://www.mega-nerd.com/libsndfile/) library not found.
Directories to search for the libraries can be specified in the
site.cfg file, in section [sndfile].
Run Code Online (Sandbox Code Playgroud)

运行pip -V回报pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

运行python …

python macos pip scikits

2
推荐指数
2
解决办法
5323
查看次数

python机器学习DeprecationWarning

你能帮帮我解决这个问题吗?

C:\ Python27\lib\site-packages\sklearn\cross_validation.py:44:DeprecationWarning:在0.18版本中不推荐使用此模块,而是支持所有重构的类和函数都移动到的model_selection模块.另请注意,新CV迭代器的接口与此模块的接口不同.该模块将在0.20中删除."此模块将在0.20中删除.",DeprecationWarning)

machine-learning scipy scikits scikit-learn

2
推荐指数
1
解决办法
3683
查看次数

Scikit 学习支持向量机的多类分类

我想知道LinearSVC默认情况下是否支持多类分类还是我们必须OneVsRestClassifier像这样包装它 :

 OneVsRestClassifier(LinearSVC())
Run Code Online (Sandbox Code Playgroud)

machine-learning svm scikits scikit-learn

1
推荐指数
1
解决办法
2267
查看次数

随机梯度增强提供了不可预测的结果

我正在使用用于Python的Scikit模块来实现随机梯度增强。我的数据集具有2700个实例和1700个特征(x),并包含二进制数据。我的输出向量是“ y”,并且包含0或1(二进制分类)。我的代码是

gb = GradientBoostingClassifier(n_estimators=1000,learn_rate=1,subsample=0.5) gb.fit(x,y)

print gb.score(x,y)

一旦运行,它的精度为1.0(100%),有时我的精度约为0.46(46%)。知道为什么其性能如此巨大的差距吗?

python machine-learning scikits scikit-learn

0
推荐指数
1
解决办法
1536
查看次数

使用skvideo.io.FFmpegWriter从相机写入帧

我试图用精确控制在飞行中拍摄的摄像机图像帧的视频编码skvideo.io.FFmpegWritercv2.VideoCapture,如

from skvideo import io
import cv2

fps = 60
stream = cv2.VideoCapture(0)                    # 0 is for /dev/video0
print("fps: {}".format(stream.set(cv2.CAP_PROP_FPS, fps)))

stream.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
stream.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
print("bit_depth: {}".format(stream.set(cv2.CAP_PROP_FORMAT, cv2.CV_8U)))

video = io.FFmpegWriter('/tmp/test_ffmpeg.avi', 
            inputdict={'-r': fps, '-width': 1920, '-height': 1080},
            outputdict={'-r': fps, '-vcodec': 'libx264', '-pix_fmt': 'h264'}
)

try:
    for i in range(fps*10):  # 10s of video
        ret, frame = stream.read()
        video.writeFrame(frame)
finally:
    stream.release()

try:
    video.close()
except:
    pass
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下异常(在Jupyter笔记本中):

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

<ipython-input-33-007a547c4229> in <module>()
     18 …
Run Code Online (Sandbox Code Playgroud)

python opencv ffmpeg video-capture scikits

0
推荐指数
1
解决办法
1693
查看次数