Skip to content
Advertisement

__init__() got an unexpected keyword argument ‘handle_unknown’

I’m trying to Ordinal Encode my categorical features using sklearn, but I get the error __init__() got an unexpected keyword argument 'handle_unknown' when I compile the below code:

  oe_l = OrdinalEncoder(handle_unknown ='use_encoded_value',unknown_value = -1)
  oe_y = OrdinalEncoder(handle_unknown ='use_encoded_value', unknown_value = -1)

  oe_l.fit(train_d['Language'])
  oe_y.fit(train_d['Year'])

  train_d['Language'] = oe_l.transform(train_d['Language'])
  test_d['Language'] = oe_l.transform(test_d['Language'])

  train_d['Year'] = oe_y.transform(train_d['Year'])
  test_d['Year'] = oe_y.transform(test_d['Year'])

A sample data to reproduce the error:

df = {'Abstract': {0: 'The present study investigates an inventory model for non-instantaneous deteriorating items under inflationary conditions with partially backlogged shortages. In today’s market structure consumers are looking for goods for which there is a delay in deterioration. At the same time, the consumers’ willingness to wait has been decreased over time, which leads to lost sales. Moreover in financial decision-making, the effects of inflation and time value of money cannot be oblivious to an inventory system. In this scenario, managing inventory of goods remains a challenging task for the decision makers, who may also have to rent warehouse under different prevailing factors such as, bulk discount, limited space in the retail outlet, or increasing inflation rates. With a focus on reduction of costs and increasing customer service, warehouse decision models are crucial for an organization’s profitability. Hence a mathematical model has been developed in the view of above scenario, in order to determine the optimal policy for the decision maker, by minimizing the present worth of total cost. The optimization procedure has been illustrated by a numerical example and detailed sensitivity analysis of the optimal solution has been performed to showcase the effect of various parameters. Managerial implications has also been presented to aid the decision making process.rn',
  1: 'AIM: To investigate the clinical characteristics and surgical treatment fororbital wall fracture of soldiers. METHODS: This study choose 58 soldiers(58 eyes)who had surgical treatments for orbital wall fracture in our hospital from January 1st, 2015 to December 31st, 2018. Their demographic characteristics, causes of injury, fracture sites, preoperative and postoperative visual acuity, eye movement, eye prominence, and operative conditions were recorded and statistically analyzed. The patients were followed up for 6mo after treatment. RESULTS: All patients in 58 cases of orbital wall fractures were male. The P50 age of them was 21, and most of them were 20-29 years old(78%). 45 cases(78%)were injured at work, in which boxing injury and impingement injury were the main causes(74%). Simple medial orbital wall, inferior wall and both of the medial and inferior wall fractures were the common types(91%). The visual acuity of all the patients did not change significantly after operation comparing with preoperative visual acuity. According to the clinical data of postoperative CT and postoperative follow up, no implant displacement, infection or other serious complications appeared. Eye movement disorder of 33 patients were improved. Abnormal suborbital perception of 7 patients disappeared. And enophthalmos of 3 patients were corrected. CONCLUSION: Young male soldiers are the main population of orbital wall fracture. It is of great significance to improve the protection in daily training. Surgical treatment for orbital wall fractures has significant therapeutic effect. Furthermore, it is very necessary for primary hospital to develop basic diagnosis and treatment.',
  2: 'Aflatoxin M1 (AFM1) and ochratoxin A (OTA), which widely coexist in milk, may pose a serious threat to human health. Mucin is a major component of the intestinal mucus layer, which plays an important role in maintaining intestinal mucosal homeostasis. However, the effect of mycotoxins AFM1 and OTA on intestinal mucin production is still not clear. This study aimed to investigate individual and interactive effects of mycotoxins AFM1 and OTA on the intestinal barrier and the mRNA expression of intestinal mucin (MUC2, MUC5AC and MUC5B) and on protein production in Caco-2/HT29-MTX cultures after 48 h of exposure. Our results show that individual mycotoxins and their mixtures significantly reduced intestinal cell viability and transepithelial electrical resistance (TEER) values, as well as significantly altered intestinal mucin mRNA expression and protein abundance. Moreover, OTA showed toxicity similar to AFM1 in cell viability and TEER value at the same concentration. When the two mycotoxins acted in combination, the synergistic effects observed in the assessment of cell viability and protein abundance in all mono- and co-cultures. In general, this study provides evidence that AFM1 and OTA can damage the intestine, and it contributes to optimized maximum permissible limits of mycotoxins in milk.',
  3: 'Background/Aim: There are still unrevealed treasures of traditional dental medicine that are the reason to investigate and present various ways in treatment of oral and orofacial tissues as well as magic and religious elements involved in representative areas among Serbs. Methods: Information was collected from the elderly non-professional folk dentists and herbalists with additional help from local physicians and dentists that was done through questionnaire and personal interviews. Results: Classified and prepared material consists of total 1038 enquiry sheets. The 41 data were averagely obtained by inquiry form i.e. 41984 information for the whole research. The most voluminous was group of 64 recipes: gums diseases 39 and toothache 25 while only seven for magic way of treatment. Among them 18 prescriptions were of non-herbal origin. The study revealed 84 herbal original prescriptions including 67 plant species (29 families) including local name, synonyms and preparation mode. Traditional healers used predominantly herbal recipes to treatpainful tooth, gum disease, blisters - herpetic ulcers /lips and mouth/, stomatitis /painful mouth, ptyalismus/, maxillary sinusitis, bad breath, teeth cleaning and bleaching. Very few methods of treatment appeared as inadequate (magical practice), whereas majority were noted as beneficial ones (herbal medicine). Still many people in distant non-urban areas use various plant recipes especially as the first aid in oral disease healing. Conclusions: The significance of plants obtained from unpolluted areas whose active ingredients have not yet been used in dental pharmaceutics should be investigated further. nnKEY WORDS: medicinal plants, ethnomedicine, dental ethnopharmacology, traditional dentistry, phytotherapy [J Complement Med Res 2017; 6(2.000): 223-233]',
  4: 'Impairment in empathy has been demonstrated in patients with schizophrenia and individuals with psychosis proneness. In the present study, we examined the neural correlates underlying theory of mind (ToM) and empathy and the relationships between these two social cognitive abilities with schizotypy. Fifty-six first-year college students (31 males, 25 females) between 17 and 21 years of age (M = 19.3, SD = 0.9) from a medical university in China participated. All participants undertook a comic strips functional imaging task that specifically examined both empathy and ToM. In addition, they completed two self-report scales: the Chapman Psychosis Proneness scale and the Interpersonal Responsivity Index (IRI). Results showed that both empathy and ToM conditions of the task were associated with brain activity in the middle temporal gyrus, the temporo-parietal junction (TPJ), the precuneus, and the posterior cingulate gyrus. In addition, we found positive correlations between negative schizotypy and brain activity in regions involved in social cognition, namely, the middle temporal gyrus, the TPJ, as well as the medial prefrontal gyrus. These findings highlight that different dimensions of schizotypy may show different associations with brain regions involved in social cognitive abilities. More importantly, the positive correlation between brain activity and anhedonia suggests the presence of compensatory mechanisms in high-risk populations.'},
 'Language': {0: 'en', 1: 'en', 2: 'en', 3: 'en', 4: 'en'},
 'Title': {0: 'Replenishment policy for non-instantaneous deteriorating items in a two storage facilities under inflationary conditions ',
  1: "Analysis of soldiers' orbital wall fracture surgical treatment in General Hospital of Northen Theater Command",
  2: 'Modulation of Mucin (MUC2, MUC5AC and MUC5B) mRNA Expression and Protein Production and Secretion in Caco-2/HT29-MTX Co-Cultures Following Exposure to Individual and Combined Aflatoxin M1 and Ochratoxin A',
  3: 'Traditional dentistry knowledge among Serbs in several Balkan countries',
  4: 'Dimensional schizotypy and social cognition: An fMRI imaging study'},
 'Year': {0: 2016, 1: 2019, 2: 2019, 3: 2017, 4: 2015},
 'id': {0: 1, 1: 2, 2: 3, 3: 4, 4: 5},
 'total_rel_score': {0: 0.6306818182,
  1: 0.5833333333,
  2: 0.3722222222,
  3: 0.6617647059,
  4: 0.3737373737}}

Could someone please tell me what’s wrong in my code?

Advertisement

Answer

You are most likely not using an appropriate version of scikit-learn.

handle_unknown and unknown_value were added to OrdinalEncoder with the release of version 0.24.0 (see release history).

Check your version of scikit-learn and upgrade if necessary.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement