<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic XGBModel' object has no attribute 'feature_types' in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6199#M278</link>
    <description>&lt;P&gt;I saved an xgboost boost model in filetstore as a pkl file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I call the model by the commands below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;model = pickle.load(open('/.../model.pkl', 'rb'))&lt;/P&gt;&lt;P&gt;model.predict_proba(df[features])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model has been running for sometime with the above commands but I now get an error saying&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'XGBModel' object has no attribute 'feature_types'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried specifying the version of the xgboost library installation but that does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be the issue?&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2023 21:27:06 GMT</pubDate>
    <dc:creator>MichaelO</dc:creator>
    <dc:date>2023-04-07T21:27:06Z</dc:date>
    <item>
      <title>XGBModel' object has no attribute 'feature_types'</title>
      <link>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6199#M278</link>
      <description>&lt;P&gt;I saved an xgboost boost model in filetstore as a pkl file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I call the model by the commands below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;model = pickle.load(open('/.../model.pkl', 'rb'))&lt;/P&gt;&lt;P&gt;model.predict_proba(df[features])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model has been running for sometime with the above commands but I now get an error saying&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'XGBModel' object has no attribute 'feature_types'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried specifying the version of the xgboost library installation but that does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be the issue?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 21:27:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6199#M278</guid>
      <dc:creator>MichaelO</dc:creator>
      <dc:date>2023-04-07T21:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: XGBModel' object has no attribute 'feature_types'</title>
      <link>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6200#M279</link>
      <description>&lt;P&gt;@Michael Okelola​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error message 'XGBModel' object has no attribute 'feature_types' suggests that the XGBModel object does not have the attribute feature_types. This could happen if the model object was saved with an older version of XGBoost that did not include the feature_types attribute or if the model object was saved with a different library or version that did not have this attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One possible solution is to retrain the XGBoost model with the latest version of XGBoost library and ensure that the feature_types attribute is included. Alternatively, you can try to investigate how the &lt;/P&gt;&lt;P&gt;XGBModel object was created and saved in the first place to determine if there were any issues with the saving process that might have caused the missing attribute. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option is to use the get_booster() method of the XGBModel object to obtain the underlying XGBoost Booster object, and then call the set_feature_types() method of the Booster object to set the feature types manually. Here's an example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import xgboost as xgb
&amp;nbsp;
model = pickle.load(open('/.../model.pkl', 'rb'))
booster = model.get_booster()
booster.set_feature_types({'feature_name': 'feature_type'})
probs = booster.predict(dmatrix)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the code above, you would replace feature_name with the actual name of your feature, and  feature_type with the type of your feature, such as 'int' or 'float'. You can specify the feature types for all the features in your dataset this way.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 12:53:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6200#M279</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-10T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: XGBModel' object has no attribute 'feature_types'</title>
      <link>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6201#M280</link>
      <description>&lt;P&gt;Hi @Michael Okelola​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for posting your question in our community! We are happy to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:32:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6201#M280</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-11T13:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: XGBModel' object has no attribute 'feature_types'</title>
      <link>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6202#M281</link>
      <description>&lt;P&gt;This is a model that has been running for some time and nothing was changed of recent, so as much as what you said makes sense, it was not the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I finally resolved the matter by changing the version of the cluster. I realized that the latest cluster is using the latest version of python which was just released 2 days to the error above. By changing the cluster version to 9.1 LTS, the error message no longer came up. Weird one, I know right.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 08:41:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/xgbmodel-object-has-no-attribute-feature-types/m-p/6202#M281</guid>
      <dc:creator>MichaelO</dc:creator>
      <dc:date>2023-05-05T08:41:43Z</dc:date>
    </item>
  </channel>
</rss>

