我知道这是一个开放式的问题,但是有一个PHP框架被普遍称赞为"最好的"吗?
谢谢.
我跑
Y_testing_obtained = classify(X_testing, X_training, Y_training);
Run Code Online (Sandbox Code Playgroud)
而我得到的错误是
Error using ==> classify at 246
The pooled covariance matrix of TRAINING must be positive definite.
Run Code Online (Sandbox Code Playgroud)
X_training是1550 x 5矩阵.你能告诉我这个错误意味着什么,即为什么会出现,以及如何解决它?谢谢
我需要实现SVM数字分类器的概念.它应该是我在画布中写入的分类输入的简单.但我需要从头开始实施.语言并不重要.
任何人都可以一步一步地指导我如何做到这一点.任何材料链接都会有所帮助.但我需要一些与实践相关的东西而不是理论.因为我已经阅读了一些关于它的理论文章.并且有基本的想法它应该如何工作,但仍然有一些麻烦如何将这些想法转换为现实生活中的例子.
非常感谢.
我试图使用scikit-learn进行分类任务.我的代码从数据中提取特征,并将它们存储在字典中,如下所示:
feature_dict['feature_name_1'] = feature_1
feature_dict['feature_name_2'] = feature_2
Run Code Online (Sandbox Code Playgroud)
当我分割数据以便使用sklearn.cross_validation一切正常工作来测试它时.我遇到的问题是当测试数据是新集时,而不是学习集的一部分(尽管它对每个样本具有相同的确切特征).在我将分类器放在学习集上之后,当我尝试调用时,clf.predict我得到了这个错误:
ValueError: X has different number of features than during model fitting.
Run Code Online (Sandbox Code Playgroud)
我假设这与此有关(在DictVectorizer文档中):
在fit或fit_transform期间未遇到的命名要素将被默默忽略.
DictVectorizer 我已经删除了一些功能...我如何禁用/解决此功能?
谢谢
===编辑===
问题是larsMans建议我适应DictVectorizer两次.
我使用以下代码来计算使用RandomForest作为分类器的灵敏度,特异性,NPV和PPV .
suppressMessages(require(randomForest));
classifier <- randomForest(x.train,y.train,ntree=300,importance=T)
prediction <<- predict(classifier,x.test,type="response")
suppressMessages(require(caret));
accuracyData <- confusionMatrix(prediction,y.test)
Run Code Online (Sandbox Code Playgroud)
在accuracyData中,我有关于预测质量的所有信息(灵敏度,特异性等).
无论如何,我想对不同的阈值进行此计算,但我不知道如何在我的代码中指定这样的值.
我知道什么是SRM,但我不理解SRM和SVM之间的关系.谁能解释一下这个?为什么他们说SVM依赖于SRM方法?非常感谢!
我的问题是
我想建立一个一类SVM分类器,以从测试文件中识别名词/方面。培训文件包含名词列表。该测试包含单词列表。
这是我所做的:
我正在使用Weka GUI,并且已经训练了一个类SVM(libSVM)以获取模型。
现在,模型将测试文件中的这些单词分类,分类器在生成的模型中将这些单词识别为名词。其他分类为离群值。(因此,它就像查找一样工作。如果在经过训练的模型中将其标识为名词,则为“是”,否则为“否”。)
那么如何建立适当的分类器呢?(我的意思是输入的格式及其应包含的信息是什么?)
注意:
编辑 我的测试文件将包含名词短语。因此,我的分类器的工作是从测试文件中的候选项中获取名词词。
我尝试在没有StringIndexer的Pipeline中使用Spark ML DecisionTreeClassifier,因为我的功能已被索引为(0.0; 1.0).DecisionTreeClassifier作为标签需要double值,因此此代码应该有效:
def trainDecisionTreeModel(training: RDD[LabeledPoint], sqlc: SQLContext): Unit = {
import sqlc.implicits._
val trainingDF = training.toDF()
//format of this dataframe: [label: double, features: vector]
val featureIndexer = new VectorIndexer()
.setInputCol("features")
.setOutputCol("indexedFeatures")
.setMaxCategories(4)
.fit(trainingDF)
val dt = new DecisionTreeClassifier()
.setLabelCol("label")
.setFeaturesCol("indexedFeatures")
val pipeline = new Pipeline()
.setStages(Array(featureIndexer, dt))
pipeline.fit(trainingDF)
}
Run Code Online (Sandbox Code Playgroud)
但实际上我得到了
java.lang.IllegalArgumentException:
DecisionTreeClassifier was given input with invalid label column label,
without the number of classes specified. See StringIndexer.
Run Code Online (Sandbox Code Playgroud)
当然我可以放置StringIndexer并让它为我的双"标签"字段工作,但我想使用DecisionTreeClassifier的输出rawPrediction列来获得每行0.0和1.0的概率,如...
val predictions = model.transform(singletonDF)
val zeroProbability = predictions.select("rawPrediction").asInstanceOf[Vector](0)
val …Run Code Online (Sandbox Code Playgroud) scala classification apache-spark apache-spark-sql apache-spark-ml
当我们训练神经网络时,我们通常使用梯度下降,这依赖于连续的,可微分的实值成本函数。最终成本函数可能会产生均方误差。或者换种说法,梯度下降隐式地认为最终目标是回归 -最大限度地减少实值误差度量。
有时,我们希望神经网络要做的就是执行分类 -给定输入,将其分类为两个或多个离散类别。在这种情况下,用户关心的最终目标是分类准确性-正确分类的案例的百分比。
但是,当我们使用神经网络进行分类时,尽管我们的目标是分类准确度,但这并不是神经网络试图优化的目标。神经网络仍在尝试优化实值成本函数。有时这些指向同一方向,但有时却不同。特别是,我一直在遇到这样的情况:经过训练以正确最小化成本函数的神经网络具有比简单的手工编码阈值比较差的分类精度。
我已经使用TensorFlow将其简化为一个最小的测试用例。它建立一个感知器(无隐藏层的神经网络),在绝对最小的数据集(一个输入变量,一个二进制输出变量)上训练它,评估结果的分类精度,然后将其与简单手的分类精度进行比较编码的阈值比较;结果分别是60%和80%。直观地讲,这是因为具有大输入值的单个离群值会产生相应的大输出值,因此,将成本函数最小化的方法是,在对两种以上普通情况进行错误分类的过程中,要尽最大努力适应这种情况。感知器正确地执行了被告知要执行的操作;只是这与我们实际想要的分类器不符。
我们如何训练神经网络,使其最终最大化分类精度?
import numpy as np
import tensorflow as tf
sess = tf.InteractiveSession()
tf.set_random_seed(1)
# Parameters
epochs = 10000
learning_rate = 0.01
# Data
train_X = [
[0],
[0],
[2],
[2],
[9],
]
train_Y = [
0,
0,
1,
1,
0,
]
rows = np.shape(train_X)[0]
cols = np.shape(train_X)[1]
# Inputs and outputs
X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
# Weights
W = tf.Variable(tf.random_normal([cols]))
b = tf.Variable(tf.random_normal([]))
# Model
pred …Run Code Online (Sandbox Code Playgroud) classification machine-learning neural-network gradient-descent loss-function
当我尝试运行预训练的MobileNet分类时,我在帖子标题中收到错误.我用来运行脚本的图像位于我的'MobileNet-inference-images/American_Cam.jpg目录中.
任何帮助或建议将不胜感激.
这是我的脚本,我的环境,错误追溯,以及到目前为止调查的内容.
import numpy as np
import keras
from keras import backend as K
from keras.layers.core import Dense
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Model
from keras.applications import imagenet_utils
from sklearn.metrics import confusion_matrix
import itertools
import matplotlib.pyplot as plt
%matplotlib inline
mobile =keras.applications.mobilenet.MobileNet()
def prepare_image(file):
img_path = 'MobileNet-inference-images/'
img = image.load_img(img_path + file, target_size=(224, 224))
img_array = image.img_to_array(img)
img_array_expanded_dims = np.expand_dims(img_array, axis=0)
return
keras.applications.mobilenet.preprocess_imput(img_array_expanded_dims)
preprocessed_image = prepare_image('MobileNet-inference-images/American_Cam.jpg')
predictions = mobile.predict(preprocessed_image) …Run Code Online (Sandbox Code Playgroud) classification ×10
python ×2
svm ×2
apache-spark ×1
arff ×1
frameworks ×1
keras ×1
libsvm ×1
matlab ×1
php ×1
python-3.x ×1
r ×1
scala ×1
scikit-learn ×1
weka ×1