目前,一些垃圾邮件浪潮,尤其是体育赛事发生时,正在泛滥互联网.
由于我强烈怀疑垃圾邮件发送者的用户名不是由计算机生成的,我认为以某种方式尝试以编程方式学习垃圾邮件发送者名称可能会很有趣.
用户名应介于2到15个字符之间,以字母开头,仅包含字母,数字_或-.
名称的样本列表将是
riazsports0171
maya34444
thelmaeatons
tigran777
newlive100
darbeshbaba
litondina10
nithuhasan
newlive100
bankuali
lldztwydni554
monomala505
nasiruddin1500
lldztwydni554
ariful3032
nazmulhasan
Run Code Online (Sandbox Code Playgroud)
我只有相当基本的算法知识(来自大学).我的问题是,我可以使用哪种机器学习算法和/或字符串度量来预测仲裁用户名是否可能是垃圾邮件发送者.我想过使用cosine string similaritz,因为它相当简单.
string algorithm machine-learning similarity feature-engineering
因此,我希望将两组功能进行分类(分类),然后合并以创建新功能。它与将坐标分类为地图上的网格一样。
问题在于要素的分布不均匀,并且pandas.qcut()在对两个要素/坐标进行装仓(如时)时,我想使用分位数。
是否有比同时qcut()使用两个功能和然后将结果标签串联更好的方法?
我有一组包含 50 个特征(c1、c2、c3 ...)的数据,行数超过 80k。
每行包含标准化数值(范围 0-1)。它实际上是一个标准化的虚拟变量,其中一些行只有很少的特征,3-4(即如果没有值则分配0)。大多数行大约有 10-20 个特征。
我使用 KMeans 对数据进行聚类,结果总是产生一个包含大量成员的集群。经过分析,我注意到少于 4 个特征的行往往会聚集在一起,这不是我想要的。
有没有办法平衡集群?
python cluster-analysis k-means data-science feature-engineering
Featuretools 支持已经处理多个截止时间https://docs.featuretools.com/automated_feature_engineering/handling_time.html
In [20]: temporal_cutoffs = ft.make_temporal_cutoffs(cutoffs['customer_id'],
....: cutoffs['cutoff_time'],
....: window_size='3d',
....: num_windows=2)
....:
In [21]: temporal_cutoffs
Out[21]:
time instance_id
0 2011-12-12 13458
1 2011-12-15 13458
2 2012-10-02 13602
3 2012-10-05 13602
4 2012-01-22 15222
5 2012-01-25 15222
In [22]: entityset = ft.demo.load_retail()
In [23]: feature_tensor, feature_defs = ft.dfs(entityset=entityset,
....: target_entity='customers',
....: cutoff_time=temporal_cutoffs,
....: cutoff_time_in_index=True,
....: max_features=4)
....:
In [24]: feature_tensor
Out[24]:
MAX(order_products.total) MIN(order_products.unit_price) STD(order_products.quantity) COUNT(order_products)
customer_id time
13458.0 2011-12-12 201.960 0.3135 10.053804 394
2011-12-15 201.960 0.3135 10.053804 394 …Run Code Online (Sandbox Code Playgroud) python feature-extraction pandas feature-engineering featuretools
假设我们有以下带有列名的 df 。
df = pd.DataFrame({
'names':['Alan', 'Alan', 'John', 'John', 'Alan', 'Alan','Alan', np.nan, np.nan, np.nan, np.nan, np.nan, 'Christy', 'Christy','John']})
Run Code Online (Sandbox Code Playgroud)
>>> df
names
0 Alan
1 Alan
2 John
3 John
4 Alan
5 Alan
6 Alan
7 NaN
8 NaN
9 NaN
10 NaN
11 NaN
12 Christy
13 Christy
14 John
Run Code Online (Sandbox Code Playgroud)
我想在列上运行一个应用函数,该函数返回特定值出现的最大连续次数。起初,我想对 NaN 执行此操作,但扩展后想切换到列中的任何其他值。
解释:如果我们对 Nan 运行 apply,结果将为 5,因为 5 是 NaN 连续出现的最高次数。如果列中其他值后面有后续行,并且 NaN 连续出现超过 5 次,则结果就是这样。
如果我们运行 apply for Alan,结果将是 3,因为 3 将在连续 Alan 第一次出现时取代 2。
我有一个与金融交易数据集相关的问题。我有两个数据集:
第一个包含带有时间戳的金融交易。
Account_from Account_to Value Timestamp
1 1 2 25 1
2 1 3 25 1
3 2 1 50 2
4 2 3 20 2
5 2 4 25 2
6 1 2 40 3
7 3 1 20 3
8 2 4 25 3
Run Code Online (Sandbox Code Playgroud)
另一个数据集包含帐户信息:
Account_id initial deposit
1 1 200
2 2 100
3 3 150
4 4 200
Run Code Online (Sandbox Code Playgroud)
现在我想创建一个包含金融交易和原始账户余额的数据集。此外,我希望账户余额随着每笔交易的时间而变化,例如:
Account_from Account_to Value Timestamp Initial_deposit Old_bal_org New_bal_org Old_bal_des New_bal_des
1 1 2 25 1 200 200 175 …Run Code Online (Sandbox Code Playgroud) 您好,我正在研究pandas数据框,我想创建一个包含多个列并对其应用条件的列,我正在寻找一种做到这一点的聪明方法。
假设数据框看起来像
A B C D
1 0 0 0
0 1 0 0
0 0 1 0
1 0 1 0
1 1 1 0
0 0 1 1
Run Code Online (Sandbox Code Playgroud)
我的输出列应如下
A B C D Output_col
1 0 0 0 A
0 1 0 0 B
0 0 1 0 C
1 0 1 0 A_C
1 1 1 0 A_B_C
0 0 1 1 C_D
Run Code Online (Sandbox Code Playgroud)
我当然可以使用下面的代码来实现这一点,但是我必须对每一列都做到这一点。
test['Output_col'] = test.A.apply(lambda x: A if x > 0 else 0)
Run Code Online (Sandbox Code Playgroud)
我想知道是否有一种方法可以在我有很多列的情况下不应用每一列而实现这一目标。
提前致谢 …
最近我学习使用 tidymodels 来构建机器学习工作流程,但是当我使用该工作流程对测试集进行预测时,它会引发错误“列中缺少数据”,但我确信训练集和测试集都没有有缺失数据。这是我的代码和示例:
\n# Imformation of the data\xef\xbc\x9athe Primary_type in test set has several novel levels\nstr(train_sample)\ntibble [500,000 x 3] (S3: tbl_df/tbl/data.frame)\n $ ID : num [1:500000] 6590508 2902772 6162081 7777470 7134849 ...\n $ Primary_type: Factor w/ 29 levels "ARSON","ASSAULT",..: 16 8 3 3 28 7 3 4 25 15 ...\n $ Arrest : Factor w/ 2 levels "FALSE","TRUE": 2 1 1 1 1 2 1 1 1 1 ...\n\nstr(test_sample)\ntibble [300,000 x 3] (S3: tbl_df/tbl/data.frame)\n $ ID : num [1:300000] …Run Code Online (Sandbox Code Playgroud) pandas ×4
python ×4
dataframe ×2
r ×2
algorithm ×1
data-science ×1
featuretools ×1
k-means ×1
python-3.x ×1
similarity ×1
string ×1
tidymodels ×1