Code Monkey home page Code Monkey logo

Comments (9)

niltecedu avatar niltecedu commented on June 14, 2024 3

Hey @trivialfis

Here are the feature names:

['t_2m:C_53.77_1.702', 't_2m:C_53.84_1.767', 't_2m:C_53.9_1.832', 't_2m:C_53.97_1.897', 't_2m:C_54.03_1.962', 't_2m:C_54.1_2.027', 'wind_speed_10m:ms_53.77_1.702', 'wind_speed_10m:ms_53.84_1.767', 'wind_speed_10m:ms_53.9_1.832', 'wind_speed_10m:ms_53.97_1.897', 'wind_speed_10m:ms_54.03_1.962', 'wind_speed_10m:ms_54.1_2.027', 'wind_speed_100m:ms_53.77_1.702', 'wind_speed_100m:ms_53.84_1.767', 'wind_speed_100m:ms_53.9_1.832', 'wind_speed_100m:ms_53.97_1.897', 'wind_speed_100m:ms_54.03_1.962', 'wind_speed_100m:ms_54.1_2.027', 'wind_dir_10m:d_53.77_1.702', 'wind_dir_10m:d_53.84_1.767', 'wind_dir_10m:d_53.9_1.832', 'wind_dir_10m:d_53.97_1.897', 'wind_dir_10m:d_54.03_1.962', 'wind_dir_10m:d_54.1_2.027', 'wind_dir_100m:d_53.77_1.702', 'wind_dir_100m:d_53.84_1.767', 'wind_dir_100m:d_53.9_1.832', 'wind_dir_100m:d_53.97_1.897', 'wind_dir_100m:d_54.03_1.962', 'wind_dir_100m:d_54.1_2.027', 'precip_1h:mm_53.77_1.702', 'precip_1h:mm_53.84_1.767', 'precip_1h:mm_53.9_1.832', 'precip_1h:mm_53.97_1.897', 'precip_1h:mm_54.03_1.962', 'precip_1h:mm_54.1_2.027', 'relative_humidity_2m:p_53.77_1.702', 'relative_humidity_2m:p_53.84_1.767', 'relative_humidity_2m:p_53.9_1.832', 'relative_humidity_2m:p_53.97_1.897', 'relative_humidity_2m:p_54.03_1.962', 'relative_humidity_2m:p_54.1_2.027', 'Wind_MWh_credit', 'windlimit']

Here is the constraints python value being passed to the regressor object

{'wind_speed_10m:ms_53.77_1.702': 1, 'wind_speed_10m:ms_53.84_1.767': 1, 'wind_speed_10m:ms_53.9_1.832': 1, 'wind_speed_10m:ms_53.97_1.897': 1, 'wind_speed_10m:ms_54.03_1.962': 1, 'wind_speed_10m:ms_54.1_2.027': 1, 'wind_speed_100m:ms_53.77_1.702': 1, 'wind_speed_100m:ms_53.84_1.767': 1, 'wind_speed_100m:ms_53.9_1.832': 1, 'wind_speed_100m:ms_53.97_1.897': 1, 'wind_speed_100m:ms_54.03_1.962': 1, 'wind_speed_100m:ms_54.1_2.027': 1, 'windlimit': 1, 'relative_humidity_2m:p_53.77_1.702': -1, 'relative_humidity_2m:p_53.84_1.767': -1, 'relative_humidity_2m:p_53.9_1.832': -1, 'relative_humidity_2m:p_53.97_1.897': -1, 'relative_humidity_2m:p_54.03_1.962': -1, 'relative_humidity_2m:p_54.1_2.027': -1}

from xgboost.

trivialfis avatar trivialfis commented on June 14, 2024

Hi, could you please provide some info for us to reproduce:

  • The actual Python value of the constraint parameter.
  • The list of feature names.

from xgboost.

trivialfis avatar trivialfis commented on June 14, 2024

Hi, I tried to create a reproducer based on the parameters, but couldn't see the error:

import numpy as np
import pandas as pd
import xgboost as xgb
from sklearn.datasets import make_regression

alpha = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])

mono = {
    "wind_speed_10m:ms_53.77_1.702": 1,
    "wind_speed_10m:ms_53.84_1.767": 1,
    "wind_speed_10m:ms_53.9_1.832": 1,
    "wind_speed_10m:ms_53.97_1.897": 1,
    "wind_speed_10m:ms_54.03_1.962": 1,
    "wind_speed_10m:ms_54.1_2.027": 1,
    "wind_speed_100m:ms_53.77_1.702": 1,
    "wind_speed_100m:ms_53.84_1.767": 1,
    "wind_speed_100m:ms_53.9_1.832": 1,
    "wind_speed_100m:ms_53.97_1.897": 1,
    "wind_speed_100m:ms_54.03_1.962": 1,
    "wind_speed_100m:ms_54.1_2.027": 1,
    "windlimit": 1,
    "relative_humidity_2m:p_53.77_1.702": -1,
    "relative_humidity_2m:p_53.84_1.767": -1,
    "relative_humidity_2m:p_53.9_1.832": -1,
    "relative_humidity_2m:p_53.97_1.897": -1,
    "relative_humidity_2m:p_54.03_1.962": -1,
    "relative_humidity_2m:p_54.1_2.027": -1,
}

fname = [
    "t_2m:C_53.77_1.702",
    "t_2m:C_53.84_1.767",
    "t_2m:C_53.9_1.832",
    "t_2m:C_53.97_1.897",
    "t_2m:C_54.03_1.962",
    "t_2m:C_54.1_2.027",
    "wind_speed_10m:ms_53.77_1.702",
    "wind_speed_10m:ms_53.84_1.767",
    "wind_speed_10m:ms_53.9_1.832",
    "wind_speed_10m:ms_53.97_1.897",
    "wind_speed_10m:ms_54.03_1.962",
    "wind_speed_10m:ms_54.1_2.027",
    "wind_speed_100m:ms_53.77_1.702",
    "wind_speed_100m:ms_53.84_1.767",
    "wind_speed_100m:ms_53.9_1.832",
    "wind_speed_100m:ms_53.97_1.897",
    "wind_speed_100m:ms_54.03_1.962",
    "wind_speed_100m:ms_54.1_2.027",
    "wind_dir_10m:d_53.77_1.702",
    "wind_dir_10m:d_53.84_1.767",
    "wind_dir_10m:d_53.9_1.832",
    "wind_dir_10m:d_53.97_1.897",
    "wind_dir_10m:d_54.03_1.962",
    "wind_dir_10m:d_54.1_2.027",
    "wind_dir_100m:d_53.77_1.702",
    "wind_dir_100m:d_53.84_1.767",
    "wind_dir_100m:d_53.9_1.832",
    "wind_dir_100m:d_53.97_1.897",
    "wind_dir_100m:d_54.03_1.962",
    "wind_dir_100m:d_54.1_2.027",
    "precip_1h:mm_53.77_1.702",
    "precip_1h:mm_53.84_1.767",
    "precip_1h:mm_53.9_1.832",
    "precip_1h:mm_53.97_1.897",
    "precip_1h:mm_54.03_1.962",
    "precip_1h:mm_54.1_2.027",
    "relative_humidity_2m:p_53.77_1.702",
    "relative_humidity_2m:p_53.84_1.767",
    "relative_humidity_2m:p_53.9_1.832",
    "relative_humidity_2m:p_53.97_1.897",
    "relative_humidity_2m:p_54.03_1.962",
    "relative_humidity_2m:p_54.1_2.027",
    "Wind_MWh_credit",
    "windlimit",
]

n_features = len(fname)

X, y = make_regression(256, n_features)
X_df = pd.DataFrame(X, columns=fname)

xgb_regressor_wind = xgb.XGBRegressor(
    objective="reg:quantileerror",
    quantile_alpha=alpha,
    # n_jobs=1,
    colsample_bytree=0.8,
    gamma=0.3,
    learning_rate=0.02,
    max_depth=4,
    n_estimators=800,
    subsample=0.6,
    min_child_weight=3,
    monotone_constraints=mono,
)
xgb_regressor_wind.fit(X_df, y)

from xgboost.

niltecedu avatar niltecedu commented on June 14, 2024

Hey the problem isnt while fitting but rather while predicting, fitting the model is fine but using the fitted model causes issues

from xgboost.

trivialfis avatar trivialfis commented on June 14, 2024

@niltecedu I added a predict to the previous snippet , it works fine as well.

from xgboost.

niltecedu avatar niltecedu commented on June 14, 2024

Hey @trivialfis Oddly enough this snippet does work but when I get my actual weather data it doesnt :/
Camt seem to get to the root of the issue, the monotone dict is auto generated based on the dataframe column named,

But the columns I sent and the dict I had is was fails in my program,

from xgboost.

trivialfis avatar trivialfis commented on June 14, 2024

Is it possible that you turned the parameter into a string instead of a dictionary?

from xgboost.

trivialfis avatar trivialfis commented on June 14, 2024

Feel free to reopen if there's a way to reproduce it.

from xgboost.

niltecedu avatar niltecedu commented on June 14, 2024

Is it possible that you turned the parameter into a string instead of a dictionary?

Hey I checked it more and it looks the same, like it a dict,
The problem stems from when Im reading it from a dataframe to create my dict and looks like thats causing issues?

If I get to the bottom of it I will update, Im gonna assume its pandas bug maybe then because I can run your snippet fine

from xgboost.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.