예제 #1
0
def run_all_hierarchi_clustering(rad,
                                 date_range,
                                 boxcox=True,
                                 norm=True,
                                 params=[
                                     "bmnum", "noise.sky", "tfreq", "v", "p_l",
                                     "w_l", "slist", "elv", "time_index"
                                 ],
                                 methods=["agglomerative", "feature"],
                                 n_clusters=[20, 5]):
    """
    Invoke all partitioned clustering algorithm
    rad: Radar code
    date_range: Date range
    """
    fd = FetchData(rad, date_range)
    beams, _ = fd.fetch_data(
        v_params=["elv", "v", "w_l", "gflg", "p_l", "slist", "v_e"])
    rec = fd.convert_to_pandas(beams)
    rec["time_index"] = utils.time_days_to_index(
        [x.to_pydatetime() for x in rec["time"].tolist()])
    if boxcox: rec = utils.boxcox_tx(rec)
    if norm: rec = utils.normalize(rec, params)
    print("\n", rec.head())
    for _i, method in enumerate(methods):
        print("\n >> Running {c} clustering".format(c=method))
        model = Hierarchi(method,
                          rec[params].values,
                          n_clusters=n_clusters[_i])
        model.setup()
        model.run()

        print("\n Estimating model skills.")
        skill = Skills(model.data, model.obj.labels_)
    return
예제 #2
0
def run_all_misc_clustering(
        rad,
        date_range,
        boxcox=False,
        norm=True,
        params=["bmnum", "slist", "elv", "time_index", "v", "w_l"],
        methods=["bang", "clique"]):
    """
    Invoke all misc clustering algorithm
    rad: Radar code
    date_range: Date range
    """
    fd = FetchData(rad, date_range)
    beams, _ = fd.fetch_data(
        v_params=["elv", "v", "w_l", "gflg", "p_l", "slist", "v_e"])
    rec = fd.convert_to_pandas(beams)
    rec["time_index"] = utils.time_days_to_index(
        [x.to_pydatetime() for x in rec["time"].tolist()])
    if boxcox: rec = utils.boxcox_tx(rec)
    if norm: rec = utils.normalize(rec, params)
    print("\n", rec.head())
    for method in methods:
        print("\n >> Running {c} clustering".format(c=method))
        model = Misc(method, rec[params].values)
        model.setup()
        model.run()

        print("\n Estimating model skills.")
        skill = Skills(model.data, model.obj.labels_)
    return
예제 #3
0
def run_all_densitybased_clustering(
    rad,
    date_range,
    boxcox=False,
    norm=True,
    params=["bmnum", "v", "p_l", "w_l", "slist", "elv", "time_index"],
    methods=["dbscan", "optics", "hdbscan"],
    m_params={
        "dbscan": {
            "eps": 5.
        },
        "optics": {
            "max_eps": 7.,
            "metric": "minkowski"
        },
        "hdbscan": {
            "metric": "minkowski",
            "algorithm": "best"
        }
    }):
    """
    Invoke all densitybased clustering algorithm
    rad: Radar code
    date_range: Date range
    """
    fd = FetchData(rad, date_range)
    beams, _ = fd.fetch_data(
        v_params=["elv", "v", "w_l", "gflg", "p_l", "slist", "v_e"])
    rec = fd.convert_to_pandas(beams)
    rec["time_index"] = utils.time_days_to_index(
        [x.to_pydatetime() for x in rec["time"].tolist()])
    if boxcox: rec = utils.boxcox_tx(rec)
    if norm: rec = utils.normalize(rec, params)
    print("\n", rec.head())
    for method in methods:
        print("\n >> Running {c} clustering".format(c=method))
        model = DBased(method, rec[params].values)
        model.setup(m_params[method])
        model.run()

        print("\n Estimating model skills.")
        skill = Skills(model.data, model.obj.labels_)
    return
예제 #4
0
 def _ini_(self,
           params=[
               "bmnum", "noise.sky", "tfreq", "v", "p_l", "w_l", "slist",
               "elv", "time_index"
           ],
           v_params=["elv", "v", "w_l", "gflg", "p_l", "slist", "v_e"]):
     """
     Model initialize
     """
     print([self.stime, self.etime])
     fd = FetchData(self.rad, [self.stime, self.etime])
     beams, _ = fd.fetch_data(v_params=v_params)
     self.rec = fd.convert_to_pandas(beams)
     print(self.rec.head())
     self.rec["time_index"] = utils.time_days_to_index(
         [x.to_pydatetime() for x in self.rec["time"].tolist()])
     self.rec["time"] = getD2N(self.rec["time"].tolist())
     if hasattr(self, "boxcox") and self.boxcox:
         self.rec = utils.boxcox_tx(self.rec)
     if hasattr(self, "norm") and self.norm:
         self.rec = utils.normalize(self.rec, params)
     if self.verbose: print("\n", self.rec.head())
     return