1
$\begingroup$

I would like to visualize my features using the code below. However, I am getting an error that my features are being recognized as "nan" instead of their actual names.

Instead of the below Feature = [and then writing the features that I want], I am assigning feature = data [0,1:]. This is the first row of my data that has the features in it. I have many features that I don't want to write as string but would just like to extract from the data file directly. How can I do this and get the names of the features instead of 'nan'?

# Load the dataset
data = load_data('credit')

# Specify the features of interest
features = [
        'limit', 'sex', 'edu', 'married', 'age', 'apr_delay', 'may_delay',
        'jun_delay', 'jul_delay', 'aug_delay', 'sep_delay', 'apr_bill', 'may_bill',
        'jun_bill', 'jul_bill', 'aug_bill', 'sep_bill', 'apr_pay', 'may_pay', 'jun_pay',
        'jul_pay', 'aug_pay', 'sep_pay',
    ]

# Extract the instances and target
X = data[features]
y = data.default


from yellowbrick.features import Rank1D

# Instantiate the 1D visualizer with the Sharpiro ranking algorithm
visualizer = Rank1D(features=features, algorithm='shapiro')

visualizer.fit(X, y)                # Fit the data to the visualizer
visualizer.transform(X)             # Transform the data
visualizer.poof()                   # Draw/show/poof the data
$\endgroup$
3
  • 2
    $\begingroup$ Add full error trace. $\endgroup$ Mar 8, 2019 at 12:56
  • 2
    $\begingroup$ What is the file type you are reading in? $\endgroup$
    – Taylrl
    Mar 8, 2019 at 16:01
  • $\begingroup$ Taylrl CSV AntonioJurić, I'll add it, thanks! $\endgroup$ Mar 10, 2019 at 6:56

1 Answer 1

2
$\begingroup$

If you are reading in a csv, try;

data = pd.read_csv('filepath', header=None)

Then you can do what you were doing to read the features from the first line

$\endgroup$
1
  • $\begingroup$ when i do that, it says unhashable type! Any ideas? $\endgroup$ Mar 17, 2019 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.