vandijklab / cell2sentence

Cell2Sentence: Teaching Large Language Models the Language of Biology
Other
24 stars 4 forks source link

AttributeError: 'float' object has no attribute 'item' #4

Open ayyucedemirbas opened 2 weeks ago

ayyucedemirbas commented 2 weeks ago

Hello,

After running this cell in the Tutorial 1:

benchmark_expression_conversion(
    benchmark_output_dir=output_path,
    save_name=transformation_benchmarking_save_name,
    normalized_expression_matrix=adata.X,
    sample_size=1024,
)

I encounter this error message:


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-29-808987c0b700>](https://localhost:8080/#) in <cell line: 1>()
----> 1 benchmark_expression_conversion(
      2     benchmark_output_dir=output_path,
      3     save_name=transformation_benchmarking_save_name,
      4     normalized_expression_matrix=adata.X,
      5     sample_size=1024,

[/usr/local/lib/python3.10/dist-packages/cell2sentence/utils.py](https://localhost:8080/#) in benchmark_expression_conversion(benchmark_output_dir, save_name, normalized_expression_matrix, sample_size)
    278         "slope": [linear_reg.coef_.item()],
    279         "intercept": [linear_reg.intercept_.item()],
--> 280         "r_squared": [r_squared_score.item()],
    281         "pearson_r_statistic": [pearson_r_score.statistic.item()],
    282         "pearson_r_pvalue": [pearson_r_score.pvalue.item()],

AttributeError: 'float' object has no attribute 'item'

It seems the error is caused by trying to call .item() on a float. Instead, the direct float values could be used, or checks could be added to ensure the correct data type before calling .item().

Thank you so much!

ayyucedemirbas commented 2 weeks ago

I have submitted a pull request to solve this problem. Thanks.

SyedA5688 commented 2 weeks ago

Hi there,

Thank you for pointing this out and for making a pull request about the issue, we greatly appreciate the open-source contribution!

We've noticed similar AttributeErrors before depending on the version of certain packages used to compute these correlation scores (scipy, sklearn are the usual culprits). I will do some testing of package versions on my end, and afterwards will take another look at your pull request. Could you let me know what version of scipy and sklearn you have in your environment? Thanks again!

ayyucedemirbas commented 2 weeks ago

Hi,

Thank you so much for your time and attention.

I'm using Google Colab, which has scipy 1.13.1 and sklearn 1.5.2.

Thanks.