You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm doing some experiments about combining abess with auto-sklearn, when using MultinomialRegression for classification, the memory tends to increase very quickly and so much that it cannot be displayed on a web page, but for LinearRegression, there is no similar out-of-memory problem.
Code for Reproduction
My code is given as follows:
frompprintimportpprintfromConfigSpace.configuration_spaceimportConfigurationSpacefromConfigSpace.hyperparametersimportCategoricalHyperparameter, \
UniformIntegerHyperparameter, UniformFloatHyperparameterimportsklearn.metricsimportautosklearn.classificationimportautosklearn.pipeline.components.classificationfromautosklearn.pipeline.components.base \
importAutoSklearnClassificationAlgorithmfromautosklearn.pipeline.constantsimportDENSE, SIGNED_DATA, UNSIGNED_DATA, \
PREDICTIONSfromsklearn.datasetsimportload_breast_cancerfromsklearn.model_selectionimporttrain_test_splitimportopenmlfromabessimportMultinomialRegressionfromsklearn.ensembleimportRandomForestClassifierimportnumpyasnpimportpandasaspdfromsklearn.datasetsimportfetch_openmlfromsklearnimportpreprocessingfromsklearn.treeimportDecisionTreeClassifierimporttimeimportmatplotlib.pyplotaspltimportwarningswarnings.filterwarnings("ignore")
classAbessClassifier(AutoSklearnClassificationAlgorithm):
def__init__(self, exchange_num, random_state=None):
self.exchange_num=exchange_numself.random_state=random_stateself.estimator=Nonedeffit(self, X, y):
fromabessimportMultinomialRegressionself.estimator=MultinomialRegression()
self.estimator.fit(X, y)
returnselfdefpredict(self, X):
ifself.estimatorisNone:
raiseNotImplementedErrorreturnself.estimator.predict(X)
defpredict_proba(self, X):
ifself.estimatorisNone:
raiseNotImplementedError()
returnself.estimator.predict_proba(X)
@staticmethoddefget_properties(dataset_properties=None):
return {
'shortname': 'abess Classifier',
'name': 'abess logistic Classifier',
'handles_regression': False,
'handles_classification': True,
'handles_multiclass': True,
'handles_multilabel': False,
'handles_multioutput': False,
'is_deterministic': False,
# Both input and output must be tuple(iterable)'input': [DENSE, SIGNED_DATA, UNSIGNED_DATA],
'output': [PREDICTIONS]
}
@staticmethoddefget_hyperparameter_search_space(dataset_properties=None):
cs=ConfigurationSpace()
exchange_num=UniformIntegerHyperparameter(
name='exchange_num', lower=4, upper=6, default_value=5
)
cs.add_hyperparameters([exchange_num])
returncs# Add abess logistic classifier component to auto-sklearn.autosklearn.pipeline.components.classification.add_classifier(AbessClassifier)
cs=AbessClassifier.get_hyperparameter_search_space()
print(cs)
dataset=fetch_openml(data_id=int(29),as_frame=True)#507,183,44136X=dataset.datay=dataset.targetX.replace([np.inf,-np.inf],np.NaN,inplace=True)
## Remove rows with NaN or Inf valuesinx=X[X.isna().values==True].index.unique()
X.drop(inx,inplace=True)
y.drop(inx,inplace=True)
##use dummy variables to replace classification variables:X=pd.get_dummies(X)
## Keep only numeric columnsX=X.select_dtypes(np.number)
## Remove columns with NaN or Inf valuesnan=np.isnan(X).any()[np.isnan(X).any() ==True]
inf=np.isinf(X).any()[np.isinf(X).any() ==True]
X=X.drop(columns=list(nan.index))
X=X.drop(columns=list(inf.index))
##Encode target labels with value between 0 and 1le=preprocessing.LabelEncoder()
y=le.fit_transform(y)
X_train, X_test, y_train, y_test=train_test_split(X, y)
print(X_train.shape) #number of initial featuresprint(X_test.shape) #number of initial featurescls=autosklearn.classification.AutoSklearnClassifier(
time_left_for_this_task=60,
per_run_time_limit=10,
include={
'classifier': ['AbessClassifier'],
'feature_preprocessor': ['polynomial']
},
memory_limit=6144,
ensemble_size=1,
)
cls.fit(X_train, y_train, X_test, y_test)
predictions=cls.predict(X_test)
print("Accuracy score", sklearn.metrics.accuracy_score(y_test, predictions))
After running this code , the memory gets to about 159MB, which is not friendly for users to open an .ipynb. Again, regression does not encounter the memory-out problem.
The text was updated successfully, but these errors were encountered:
belzheng
changed the title
memory out when combining abess with auto-sklearn for classifocation.
memory out when combining abess with auto-sklearn for classification.
Sep 28, 2022
Describe the bug
I'm doing some experiments about combining abess with auto-sklearn, when using
MultinomialRegression
for classification, the memory tends to increase very quickly and so much that it cannot be displayed on a web page, but forLinearRegression
, there is no similar out-of-memory problem.Code for Reproduction
My code is given as follows:
After running this code , the memory gets to about 159MB, which is not friendly for users to open an
.ipynb
. Again, regression does not encounter the memory-out problem.The text was updated successfully, but these errors were encountered: