Home > other >  Python interval processing
Python interval processing

Time:10-08

Consult everybody a great god how is such an error?
Using the map function for operation...
TypeError: unorderable types: Interval () & gt; The int ()


Data (var). The head ()


0 (300, 750]1 (300, 750]
2 (1, 300]
3 (300, 750]
4 (750, 2000]
Name: amount of every months of reimbursement categories, dtype: category
Categories (3, the interval [int64]) : [(1, 300] <(300, 750] <(750, 2000]


WOE_dict (var)

{the Interval (1, 300, closed='right') : 0.23770096910687502,
The Interval (300, 750, closed='right') : 0.04409423969778843,
The Interval (750, 2000, closed='right') : 0.36681586177339626}

CodePudding user response:

Add some code, don't see what are you going to how to use the map, feel you when use the interval into int

CodePudding user response:

Boon boon good code below

Short_list=high_IV. Keys ()
Short_list_2=[]
For var in short_list:
NewVar=var + '_WOE'
Data (newVar)=data (var). The map (WOE_dict/var)
Short_list_2. Append (newVar)

CodePudding user response:

O god the way, thank you,

When using imblearn to do sampling first to the following error: (Python version 3.7)
Type the object 'sklearn. Manifold. _barnes_hut_tsne. Array' has no attribute '__reduce_cython__'
Online to solve the code is as follows:

AllFeatures=list (data. The columns)
AllFeatures. Remove (' Class ')
X=data [allFeatures]
Y=data [' Class ']
N_pos_sample=y/y==0] shape [0]
N_neg_sample=y/y==1] shape [0]
The import sklearn
The from imblearn. Under_sampling import ClusterCentroids
Rus=ClusterCentroids (thewire={0-4 * n_pos_sample, 1: n_neg_sample}, random_state=1)
X, y=rus. Fit_sample (X, y)
Data_X=pd. DataFrame (X, the columns=[allFeatures])
Data_y=pd. DataFrame (y, the columns=[' target '])
Data=https://bbs.csdn.net/topics/pd.concat ([data_X data_y], axis=1)

CodePudding user response:

I also encountered this problem, ask the building Lord solved?
  • Related