Giter VIP home page Giter VIP logo

Comments (6)

EgorDudyrev avatar EgorDudyrev commented on August 20, 2024

Hello Yannis!
I have not run your code yet. But I think the misconception is caused simply by the way I denote the nodes.
(And, I think, this way is default in FCA community. See https://upriss.github.io/fca/examples.html ).

Given a concept, its intent can be derived by union of attributes that are shown in concepts above the current concept. And the extent of the concept can be derived by union of objects that are shown in concepts below the current concept.
For example, for concept # 3, the intent would be {eggs, dangerous} (where "eggs" is shown in node 3 and "dangerous" is shown in node 1). The extent would be {alligator, tarantula} (where "alligator" is shown in node 6 and "tarantula" is shown in node 8).
You should get the same extent and intent of concept 3 by writing:

print(L[3].extent)
print(L[3].intent)

Visualizing the whole extent and the whole intent for each node would just overload the diagram with lots of text.

Now, if you do not like such notation, you can define you own via node_label_func parameter of draw_concept_lattice function. node_label_func should be a python function that takes an index of the concept el_i, the lattice ltc, and outputs a text to visualize.
For example:

vsl.draw_concept_lattice(
    L, ax=ax, flg_node_indices=True,
    max_new_extent_count=10, flg_new_intent_count_prefix=False, flg_new_extent_count_prefix=False,
   node_label_func = lambda el_i, ltc:  ','.join(ltc[el_i].intent) + '\n\n\n' + ','.join(ltc[el_i].extent) 
)

This code should draw the lattice with full intent and full extent for each node.

from fcapy.

EgorDudyrev avatar EgorDudyrev commented on August 20, 2024

Please, notify me if the aforementioned code does not work. Then I will have to modify the package, which might take some time.

from fcapy.

yannis1962 avatar yannis1962 commented on August 20, 2024

It does work and it is great, THANK YOU so much. Just one last query: how can I get the empty set symbol for the top and bottom nodes?

from fcapy.

EgorDudyrev avatar EgorDudyrev commented on August 20, 2024

Here, the visualization is done via networkx package which supports latex. So, I think, the following string should work fine

r"$\emptyset$"

Applied to the code above, it would be somewhat like

def full_labels_func(el_i, ltc):
   intent_str = ','.join(ltc[el_i].intent) if len(ltc[el_i].intent) > 0 else r'$\emptyset$'
   extent_str = ','.join(ltc[el_i].extent) if len(ltc[el_i].extent) > 0 else r'$\emptyset$'
   return intent_str + '\n\n\n' + extent_str

vsl.draw_concept_lattice(
    L, ax=ax, flg_node_indices=True,
    max_new_extent_count=10, flg_new_intent_count_prefix=False, flg_new_extent_count_prefix=False,
   node_label_func = full_labels_func
)

from fcapy.

yannis1962 avatar yannis1962 commented on August 20, 2024

Thank you Egor, you are really very very kind, fast and efficient! I'm very grateful! This diagram will appear in my book on NLP and you will be duly thanked in it!
Yannis
Alligator

from fcapy.

EgorDudyrev avatar EgorDudyrev commented on August 20, 2024

Thank you! It it such an honour :)

However, if this diagram is going to be published, I would propose to slightly enhance it. For example, move the node 8 somewhere above the node 10, as now it is placed too close to the line between node 7 and node 10.
I have not yet implemented the algorithm for beutiful placing of nodes (and I do not really know one). So I do all prettyfications manually. The example is presented in this tutorial: https://github.com/EgorDudyrev/FCApy_tutorials/blob/main/Lattice%20Visualization/Visualizing_lattice.ipynb
This work will take a bit more time and effort, but the result would look much nicer.

from fcapy.

Related Issues (2)

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.