A house-price model target-encodes the district column. Some new houses are in districts the encoder never saw during training.
Task: write encode_districts(train_districts, train_prices, new_districts, smooth).
"district". The prices are a list of numbers, one per training house.TargetEncoder(smooth=smooth, target_type="continuous") on the training districts and prices.new_districts with it. A district the encoder never saw gets the overall average price of the training houses.