Пример #1
0
 public LinearCoef GetDataArgsByFile()
 {
     string lines = File.ReadAllText(@"d:\linear_coef2.json");
     LinearCoef linearCoef = new LinearCoef();
     var dd = JsonConvert.DeserializeObject<LinearCoef>(lines);
     linearCoef.ListCoef = dd.ListCoef.ToList();
     //linearCoef.ListCoef = dd.ListCoef.Where(w => w.coef_type == 1).ToList();
     return linearCoef;
 }
Пример #2
0
        public float GetLinearRegression(DidiDBDetail detailData, DidiPerData fixData, LinearCoef LinearCoefData, int logisticRegression)
        {
            log.Info("GetLinearRegression data :{0}", DateTime.Now);
            if (logisticRegression == 1 || logisticRegression == 3)
            {
                Dictionary<string, float > dicLinear = new Dictionary<string, float>();
                string direction = logisticRegression == 1 ? "Increase" : "Decrease";
                dicLinear = LinearCoefData.ListCoef.Where(w => w.promo_strgy == detailData.promo_strgy && w.keyword_cat == detailData.keyword_cat && w.direction == direction).Select(s => new { s.coef_name, s.coef }).ToDictionary(x => x.coef_name, x=>x.coef);
                var ddd = LinearCoefData.ListCoef.Where(w => w.coef_type == 1).Select(s => s.coef).FirstOrDefault();
                float f_per_p = dicLinear["click"] * fixData.click
                    + dicLinear["imp"] * fixData.imp
                    + dicLinear["conv"] * fixData.conv
                    + dicLinear["roi"] * fixData.roi
                    + dicLinear["imp_rank1"] * fixData.imp_rank1
                    + dicLinear["pc_score"] * fixData.pc_score
                    + dicLinear["ctr"] * fixData.ctr
                    + dicLinear["ctr_ind"] * fixData.ctr_ind
                    + dicLinear["cpc"] * fixData.cpc
                    + dicLinear["cpc_ind"] * fixData.cpc_ind
                    + dicLinear["d_spend_ind"] * fixData.d_spend_ind
                    + dicLinear["cpc_limt_ind"] * fixData.cpc_limit_ind;

                //float f_per_p = dicLinear["click"] * fixData.click;
                //f_per_p = f_per_p + dicLinear["imp"] * fixData.imp;
                //f_per_p = f_per_p + dicLinear["conv"] * fixData.conv;
                //f_per_p = f_per_p + dicLinear["roi"] * fixData.roi;
                //f_per_p = f_per_p + dicLinear["imp_rank1"] * fixData.imp_rank1;
                // f_per_p = f_per_p + dicLinear["pc_score"] * fixData.pc_score;
                //f_per_p = f_per_p + dicLinear["ctr"] * fixData.ctr;
                //f_per_p = f_per_p + dicLinear["ctr_ind"] * fixData.ctr_ind;
                //f_per_p = f_per_p + dicLinear["cpc"] * fixData.cpc;
                //f_per_p = f_per_p + dicLinear["cpc_ind"] * fixData.cpc_ind;
                //f_per_p = f_per_p + dicLinear["d_spend_ind"] * fixData.d_spend_ind;
                //f_per_p = f_per_p + dicLinear["cpc_limt_ind"] * fixData.cpc_limit_ind;
                log.Info("GetLinearRegression data end :{0}", DateTime.Now);
                return f_per_p;
            }
            else
            {
                log.Info("GetLinearRegression data end nan :{0}", DateTime.Now);
                return float.NaN;
            }
        }