Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ottogin/raif_gg_hack into main
Browse files Browse the repository at this point in the history
  • Loading branch information
femoiseev committed Sep 25, 2021
2 parents dfa9172 + 8f1122b commit dcbfca0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from raif_hack.features import prepare_categorical
from traceback import format_exc

from raif_hack.model import BenchmarkModel, TwoStepBenchmarkModel, WeightedTwoStepModel
from raif_hack.model import *
from raif_hack.floor_processing import get_floor_nb_and_height_features
from raif_hack.streets_reforms_processing import combine_street_region, fill_reforms_500_as_1000

Expand Down Expand Up @@ -82,7 +82,7 @@ def parse_args():
test_df = prepare_categorical(test_df)

logger.info("Load model")
model = WeightedTwoStepModel.load(args["mp"])
model = WeightedBlendModel.load(args["mp"])
logger.info("Predict")
test_df["per_square_meter_price"] = model.predict(
test_df[NUM_FEATURES + CATEGORICAL_OHE_FEATURES + CATEGORICAL_STE_FEATURES]
Expand Down
8 changes: 5 additions & 3 deletions raif_hack/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ def fit(
y_val_offer: typing.Optional[pd.Series] = None,
X_val_manual: typing.Optional[pd.DataFrame] = None,
y_val_manual: typing.Optional[pd.Series] = None,
use_best_model = False,
w=0.9
):
y_offer, y_manual, y_val_offer, y_val_manual = np.log(y_offer), np.log(y_manual), np.log(y_val_offer), np.log(y_val_manual)
logger.info("Fit catboost")
Expand All @@ -564,8 +566,8 @@ def fit(
)
X_off_prep = self.pipeline3[:-1].transform(X_manual)
self.pipeline3[-1:].fit(X_off_prep, y_manual)
y_offer = 0.9*y_offer + 0.1*self.pipeline3.predict(X_offer)
y_offer = w * y_offer + (1 - w) * self.pipeline3.predict(X_offer)

X = pd.concat([X_offer, X_manual])
y = pd.concat([y_offer, y_manual])
WEIGHT = 0.05
Expand All @@ -587,7 +589,7 @@ def fit(
# + CATEGORICAL_STE_FEATURES,
# model__categorical_feature=CATEGORICAL_OHE_FEATURES
# + CATEGORICAL_STE_FEATURES,
model__use_best_model=True,
model__use_best_model=use_best_model,
model__eval_set=Pool(X_val_prep, y_val),
model__sample_weight=weight,
)
Expand Down

0 comments on commit dcbfca0

Please # to comment.