识别已知事件的Python机器学习算法 [英] Python Machine Learning Algorithm to Recognize Known Events
问题描述
我有两组数据.这些数据是电路中两点A和B的记录电压.电压A是电路的主要组件,电压B是子电路. B中的每个正电压都被认为是(1)B事件,而(2)被认为是A的合成.我已经包括了发生B电压事件4,4,0,0,4,4
的样本数据.真实的训练数据集将具有更多可用数据.
I have two sets of data. These data are logged voltages of two points A and B in a circuit. Voltage A is the main component of the circuit, and B is a sub-circuit. Every positive voltage in B is (1) considered a B event and (2) known to be composite of A. I have included sample data where there is a B voltage event, 4,4,0,0,4,4
. A real training data set would have many more available data.
如何训练Python机器学习算法来识别仅给出A数据的B事件?
How can I train a Python machine learning algorithm to recognize B events given only A data?
示例数据:
V(A), V(B)
0, 0
2, 0
5, 4
3, 4
1, 0
3, 4
4, 4
1, 0
0, 0
2, 0
5, 0
7, 0
2, 0
5, 4
9, 4
3, 0
5, 0
4, 4
6, 4
3, 0
2, 0
推荐答案
一个想法:
from sklearn.ensemble import RandomForestClassifier
n = 5
X = [df.A.iloc[i:i+n] for i in df.index[:-n+1]]
labels = (df.B > 0)[n-1:]
model = RandomForestClassifier()
model.fit(X, labels)
model.predict(X)
这是什么,它将先前的n
观测值用作'B'值的预测变量.在这个小的数据集上,它可以达到0.94的精度(可能会过拟合).
What this does is, it takes the previous n
observations as predictors for the 'B' value. On this small data set it achieves 0.94 accuracy (could be overfitting).
更正了一个小的对齐错误.
Corrected a small alignment error.
这篇关于识别已知事件的Python机器学习算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!