
hive
wgdzz
这个作者很懒,什么都没留下…
展开
-
Hive SQL 代码snippet
Hive SQL 代码snippet使用SQL计算gini指数with balances as ( select '2018-01-01' as date, balance from unnest([1,2,3,4,5]) as balance -- Gini coef: 0.2666666666666667 union all select '2018-01-02' as date, balance from unnest([3,3,3,3]) as balan原创 2020-08-29 15:48:09 · 382 阅读 · 0 评论 -
hive数组排序
hive数组排序hive中关于数组内部排序等函数主要有以下两个:sort_arraysort_array(array(obj1, obj2,…)) - Sorts the input array in ascending order according to the natural ordering of the array elements.Example:SELECT sort_ar...原创 2020-05-06 14:44:04 · 6994 阅读 · 0 评论 -
解析xgb模型成sql语句
解析xgb模型成sql语句xgb是一种功能强大,被广泛使用的树模型。树模型的本质是一组if-else组合。训练好的xgb模型如何需要对大数据进行运算,往往需要分布式的环境。Hive是我们常用的处理数据的环境,往往一些模型运算也在其中。我们可以使用以下三种方式,在Hive中计算xgb模型:使用python tranform的形式,如果没有安装xgb的包,还需要自己解析模型文件;将xgb模...原创 2019-02-27 21:05:26 · 2264 阅读 · 7 评论 -
Hive Sql 嵌套 case when(if else)
一般我们使用 hive sql 中的case when是以下两种形式CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] ENDCASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END在将xgb模型转化为sql的过程中,用嵌套判断模式,会减少计算量,因此搜索了一下如何在hive中实现嵌套格式的if-else判...原创 2019-02-28 09:21:15 · 34704 阅读 · 1 评论