Coder Social home page Coder Social logo

rdflime-util's Issues

'LimeRdfExplainer' object has no attribute 'w2v_dump'

Getting error:

'LimeRdfExplainer' object has no attribute 'w2v_dump' when following the example from https://github.com/rgrenz/rdflime-util/blob/main/notebooks/3_RDFLIME.ipynb

To facilitate things, I've reduced the movies sample to just 400. After completing the embeddings and classifier part, when running the following piece:


#reload(lime.lime_rdf)
from lime.lime_rdf import LimeRdfExplainer

# TODO ! Check if entities in correct order

explainer = LimeRdfExplainer(
    transformer=transformer, 
    entities=entities,
    class_names=clf.classes_,
    kernel=None,
    kernel_width=25,
    verbose=False,
    feature_selection="auto"
)

# Attention: Index value, not row number!
explained_idx = 1
explained_entity_row = dataset.loc[explained_idx]
explained_entity_uri = explained_entity_row['DBpedia_URI16']
embedding = transformer._embeddings[transformer._entities.index(explained_entity_uri)]
prediction = clf.predict_proba([embedding])

print("Explaining", explained_entity_uri)
print("Original prediction:", prediction, " / ".join(clf.classes_))
print("True class:", explained_entity_row['label'])

data, probabilities, distances, explanation = explainer.explain_instance(
    entity=explained_entity_uri, 
    classifier_fn=clf.predict_proba,
    num_features=10,
    num_samples=50,
    allow_triple_addition=False,
    allow_triple_subtraction=True,
    max_changed_triples=5,
    change_count_fixed=True,
    use_w2v_freeze=True,
    center_correction=False,
    single_run=False,
    train_with_all=False,
    distance_metric="cosine",
    model_regressor=None,
    short_uris=False,
    labels=(0,1)
)

Getting:

Explaining http://dbpedia.org/resource/Ratatouille_(film)
Original prediction: [[0.48323835 0.51676165]] bad / good
True class: good
Preparing perturbed walks: 100%|██████████| 50/50 [00:00<00:00, 3542.79it/s]
Average remaining walks per artificial entity (from 484): 5.6
Training perturbed W2V embeddings:   0%|          | 0/50 [00:00<?, ?it/s]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-73-71d3944b2a8a>](https://localhost:8080/#) in <module>
     41     model_regressor=None,
     42     short_uris=False,
---> 43     labels=(0,1)
     44 )

2 frames
[/usr/local/lib/python3.7/dist-packages/lime/lime_rdf.py](https://localhost:8080/#) in get_perturbed_embedding(self, entity, perturbed_entity_walks, entity_suffix)
    294 
    295         # Clone w2v instance
--> 296         w2v = pickle.loads(self.w2v_dump)
    297         # w2v.wv = pickle.loads(self.wv_dump)
    298         wv = w2v.wv

AttributeError: 'LimeRdfExplainer' object has no attribute 'w2v_dump'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.